diff --git a/main_dc/yalarba/api_yal/go.mod b/main_dc/yalarba/api_yal/go.mod index 2c7c2a5..0d8b680 100644 --- a/main_dc/yalarba/api_yal/go.mod +++ b/main_dc/yalarba/api_yal/go.mod @@ -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 diff --git a/main_dc/yalarba/api_yal/go.sum b/main_dc/yalarba/api_yal/go.sum index 77d625b..a022f00 100644 --- a/main_dc/yalarba/api_yal/go.sum +++ b/main_dc/yalarba/api_yal/go.sum @@ -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= diff --git a/main_dc/yalarba/api_yal/internal/router/router.go b/main_dc/yalarba/api_yal/internal/router/router.go new file mode 100644 index 0000000..7371e52 --- /dev/null +++ b/main_dc/yalarba/api_yal/internal/router/router.go @@ -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 +} \ No newline at end of file