package router import ( "github.com/go-chi/chi/v5" "github.com/go-chi/chi/v5/middleware" httpSwagger "github.com/swaggo/http-swagger" "code.alt-gnome.ru/aides-infra/aides-repo-api/internal/config" "code.alt-gnome.ru/aides-infra/aides-repo-api/internal/controllers/taskcontroller" "code.alt-gnome.ru/aides-infra/aides-repo-api/internal/middlewares" _ "code.alt-gnome.ru/aides-infra/aides-repo-api/docs" ) type Router struct { config *config.Config taskController *taskcontroller.TaskController } func New( config *config.Config, taskController *taskcontroller.TaskController, ) *Router { return &Router{ config: config, taskController: taskController, } } func (r *Router) Setup() *chi.Mux { router := chi.NewRouter() router.Use(middleware.Logger) authGuard := middlewares.CreateAuthGuard(r.config) router.Get("/swagger/*", httpSwagger.WrapHandler) router.Route("/tasks", func(taskRouter chi.Router) { taskRouter.With(authGuard).Post("/", r.taskController.Create) taskRouter.Route("/{taskID}", func(sTaskRouter chi.Router) { sTaskRouter.With(authGuard).Post("/upload", r.taskController.Upload) }) }) return router }