26 lines
791 B
Go
26 lines
791 B
Go
package routes
|
|
|
|
import (
|
|
"authorization/handlers"
|
|
"authorization/middleware"
|
|
"database/sql"
|
|
|
|
"github.com/gorilla/mux"
|
|
httpSwagger "github.com/swaggo/http-swagger"
|
|
)
|
|
|
|
func SetupRoutes(router *mux.Router, db *sql.DB) {
|
|
// Health check endpoints (no auth required)
|
|
router.HandleFunc("/health", handlers.HealthHandler).Methods("GET")
|
|
router.HandleFunc("/ready", handlers.ReadyHandler).Methods("GET")
|
|
|
|
// Rate limit configuration
|
|
rateLimitConfig := middleware.DefaultRateLimitConfig()
|
|
rateLimiter := middleware.RateLimiterMiddleware(rateLimitConfig)
|
|
|
|
authRoutes := router.PathPrefix("/v1/auth").Subrouter()
|
|
authRoutes.HandleFunc("/check", rateLimiter(middleware.JWTAuth(handlers.AuthorizeHandler))).Methods("POST")
|
|
|
|
router.PathPrefix("/swagger/").Handler(httpSwagger.WrapHandler)
|
|
}
|