modified: go.mod

modified:   go.sum
	new file:   internal/logger/interface.go
	new file:   internal/logger/route_logger.go
	modified:   internal/router/router.go
add router logger that logg all router in the start api_yal
This commit is contained in:
2026-03-03 15:26:29 +05:00
parent 9a3ff9ad3d
commit f25dfeacb8
5 changed files with 188 additions and 4 deletions
@@ -4,10 +4,9 @@ import (
"api_yal/internal/config"
"api_yal/internal/logger"
"encoding/json"
"net/http"
"github.com/go-chi/chi"
"github.com/go-chi/chi/v5"
"gorm.io/gorm"
"net/http"
)
func SetupRouter(db *gorm.DB, config *config.Config) http.Handler {
@@ -19,8 +18,15 @@ func SetupRouter(db *gorm.DB, config *config.Config) http.Handler {
// Health check
r.Get("/health", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
json.NewEncoder(w).Encode(map[string]string{"status": "healthy"})
})
zapLogger.Info("End setup routers")
// Логируем все зарегистрированные маршруты
routeLogger := logger.NewRouteLogger(logger.NewWrapper(zapLogger))
routeLogger.LogRoutes(r)
return r
}
}