modified: main_dc/yalarba/api_yal/go.mod

modified:   main_dc/yalarba/api_yal/go.sum
	new file:   main_dc/yalarba/api_yal/internal/router/router.go
add router.go into api_yal
This commit is contained in:
2026-02-25 12:24:45 +05:00
parent 104a006166
commit 6c0eb6d877
3 changed files with 28 additions and 0 deletions
+1
View File
@@ -15,6 +15,7 @@ require (
)
require (
github.com/go-chi/chi v1.5.5
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/joho/godotenv v1.5.1
+2
View File
@@ -1,4 +1,6 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/go-chi/chi v1.5.5 h1:vOB/HbEMt9QqBqErz07QehcOKHaWFtuj87tTDVz2qXE=
github.com/go-chi/chi v1.5.5/go.mod h1:C9JqLr3tIYjDOZpzn+BCuxY8z8vmca43EeMgyZt7irw=
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo=
@@ -0,0 +1,25 @@
package router
import (
"api_yal/internal/config"
"api_yal/internal/logger"
"encoding/json"
"github.com/go-chi/chi"
)
func SetupRouter(db *gorm.DB, config *config.Config) http.Handler {
zapLogger := logger.Get()
zapLogger.Info("Start setup routers")
r := chi.NewRouter()
// Health check
r.Get("/health", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(map[string]string{"status": "healthy"})
})
return r
}