modified: serv_nginx/api_bb/internal/handlers/auth.go
modified: serv_nginx/api_bb/internal/handlers/avatar.go modified: serv_nginx/api_bb/internal/handlers/health.go modified: serv_nginx/api_bb/internal/handlers/user.go modified: serv_nginx/api_bb/internal/routes/routes.go deleted: serv_nginx/bbvue/src/stores/counter.js modified: serv_nginx/bbvue/src/views/Profile.vue update chi to last, moove the routing from handlers to router.go
This commit is contained in:
@@ -42,25 +42,38 @@ func SetupRouter(db *gorm.DB, config *config.Config) http.Handler {
|
||||
// Initialize handlers
|
||||
|
||||
// Health routes
|
||||
r.Mount("/api", allHandler.HealthHandler().Routes())
|
||||
r.Route("/api", func(r chi.Router) {
|
||||
r.Get("/health", allHandler.HealthHandler().HealthCheck)
|
||||
r.Get("/check", allHandler.HealthHandler().Check)
|
||||
})
|
||||
|
||||
// API v1 routes
|
||||
r.Route("/v1", func(r chi.Router) {
|
||||
r.Get("/check", allHandler.HealthHandler().Check)
|
||||
|
||||
// Public auth routes
|
||||
r.Mount("/auth", allHandler.AuthHandler().Routes())
|
||||
r.Route("/auth", func(r chi.Router) {
|
||||
r.Post("/register", allHandler.AuthHandler().Register)
|
||||
r.Post("/login", allHandler.AuthHandler().Login)
|
||||
r.Post("/logout", allHandler.AuthHandler().Logout)
|
||||
})
|
||||
|
||||
// Protected routes
|
||||
r.Route("/user", func(r chi.Router) {
|
||||
r.Use(middleware.AuthMiddleware(jwtService, userRepo))
|
||||
r.Use(middleware.RequireAuth)
|
||||
|
||||
// Все операции с аватарами теперь через AvatarHandler
|
||||
r.Mount("/avatars", allHandler.AvatarHandler().Routes())
|
||||
// Профиль пользователя
|
||||
r.Mount("/", allHandler.UserHandler().Routes())
|
||||
// user profile routes
|
||||
r.Get("/profile", allHandler.UserHandler().GetProfile)
|
||||
r.Post("/editProfile", allHandler.UserHandler().UpdateProfile)
|
||||
r.Get("/", allHandler.UserHandler().GetUsers)
|
||||
|
||||
// Все операции с аватарами теперь через AvatarHandler
|
||||
r.Route("/avatars", func(r chi.Router) {
|
||||
|
||||
r.Post("/upload", allHandler.AvatarHandler().UploadAvatar)
|
||||
r.Delete("/delete", allHandler.AvatarHandler().DeleteAvatar)
|
||||
r.Get("/{filename}", allHandler.AvatarHandler().GetAvatar)
|
||||
})
|
||||
// Здесь будут другие защищенные маршруты пользователя
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user