add bb_api rest api for begushiybashkir
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
package routes
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-chi/chi/v5"
|
||||
"gorm.io/gorm"
|
||||
|
||||
"go-rest-api/internal/handlers"
|
||||
"go-rest-api/internal/repository"
|
||||
"go-rest-api/internal/service"
|
||||
"go-rest-api/pkg/middleware"
|
||||
)
|
||||
|
||||
func SetupRouter(db *gorm.DB) http.Handler {
|
||||
r := chi.NewRouter()
|
||||
|
||||
// Apply common middleware
|
||||
for _, m := range middleware.CommonMiddleware() {
|
||||
r.Use(m)
|
||||
}
|
||||
|
||||
// Initialize repositories
|
||||
userRepo := repository.NewUserRepository(db)
|
||||
|
||||
// Initialize services
|
||||
authService := service.NewAuthService(userRepo)
|
||||
|
||||
// Initialize handlers
|
||||
healthHandler := handlers.NewHealthHandler()
|
||||
authHandler := handlers.NewAuthHandler(authService)
|
||||
|
||||
// Health routes
|
||||
r.Mount("/api", healthHandler.Routes())
|
||||
|
||||
// API v1 routes
|
||||
r.Route("/api/v1", func(r chi.Router) {
|
||||
r.Mount("/auth", authHandler.Routes())
|
||||
|
||||
// Здесь будут добавлены другие маршруты:
|
||||
// r.Mount("/users", userHandler.Routes())
|
||||
// r.Mount("/events", eventHandler.Routes())
|
||||
// r.Mount("/reviews", reviewHandler.Routes())
|
||||
})
|
||||
|
||||
return r
|
||||
}
|
||||
Reference in New Issue
Block a user