diff --git a/serv_nginx/api_bb/internal/routes/routes.go b/serv_nginx/api_bb/internal/routes/routes.go index 98d3ce1..f1c6a75 100644 --- a/serv_nginx/api_bb/internal/routes/routes.go +++ b/serv_nginx/api_bb/internal/routes/routes.go @@ -32,7 +32,7 @@ func SetupRouter(db *gorm.DB, config *config.Config) http.Handler { // Initialize handlers healthHandler := handlers.NewHealthHandler() authHandler := handlers.NewAuthHandler(authService, jwtService) - userHandler := handlers.NewUserHandler(authService) + userHandler := handlers.NewUserHandler(authService) // Health routes r.Mount("/", healthHandler.Routes()) @@ -40,16 +40,23 @@ func SetupRouter(db *gorm.DB, config *config.Config) http.Handler { // API v1 routes r.Route("/v1", func(r chi.Router) { r.Get("/check", healthHandler.Check) - + // Public auth routes r.Mount("/auth", authHandler.Routes()) - r.Mount("/user", userHandler.Routes()) - + // Protected routes + r.Route("/user", func(r chi.Router) { + r.Use(middleware.AuthMiddleware(jwtService, userRepo)) + r.Use(middleware.RequireAuth) + + r.Mount("/", userHandler.Routes()) + // Здесь будут другие защищенные маршруты пользователя + }) + // Здесь будут добавлены другие маршруты: // r.Mount("/events", eventHandler.Routes()) // r.Mount("/reviews", reviewHandler.Routes()) }) return r -} \ No newline at end of file +}