diff --git a/backend/internal/router/router.go b/backend/internal/router/router.go index f055d05..6d69abb 100755 --- a/backend/internal/router/router.go +++ b/backend/internal/router/router.go @@ -62,6 +62,33 @@ func NewRouter() http.Handler { jobHandler := handlers.NewJobHandler(jobService) applicationHandler := handlers.NewApplicationHandler(applicationService) + // --- ROOT ROUTE --- + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + if r.URL.Path != "/" { + http.NotFound(w, r) + return + } + // Get client IP + clientIP := r.Header.Get("X-Forwarded-For") + if clientIP == "" { + clientIP = r.Header.Get("X-Real-IP") + } + if clientIP == "" { + clientIP = r.RemoteAddr + } + + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(http.StatusOK) + response := `{ + "message": "🐴 GoHorseJobs API is running!", + "ip": "` + clientIP + `", + "docs": "/docs", + "health": "/health", + "version": "1.0.0" +}` + w.Write([]byte(response)) + }) + mux.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) w.Write([]byte("OK")) @@ -106,8 +133,8 @@ func NewRouter() http.Handler { log.Println("S3 storage routes registered successfully") } - // Swagger Route - mux.HandleFunc("/swagger/", httpSwagger.WrapHandler) + // Swagger Route - available at /docs + mux.HandleFunc("/docs/", httpSwagger.WrapHandler) // Apply middleware chain: Security Headers -> Rate Limiting -> CORS -> Router // Order matters: outer middleware runs first