Created the main router with ping endpoint

This commit is contained in:
2025-11-14 03:13:17 +03:00
parent 185189ba85
commit 5d71f42361
4 changed files with 37 additions and 1 deletions

27
api/http_handler.go Normal file
View File

@@ -0,0 +1,27 @@
package api
import (
"fmt"
"log"
"net/http"
"github.com/gorilla/mux"
)
func ping(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, "pong")
}
func BuildRouter(listenAddress string) {
mainRouter := mux.NewRouter()
mainRouter.HandleFunc("/ping", ping)
// api_router := base_router.PathPrefix("/api").Subrouter()
err := http.ListenAndServe(listenAddress, mainRouter)
if err != nil {
log.Fatalf("Error running the web server %s", err)
}
}