2024-12-04 11:46:42 +00:00
|
|
|
package router
|
|
|
|
|
|
|
|
import (
|
2024-12-12 13:27:07 +00:00
|
|
|
"github.com/go-chi/chi/v5"
|
|
|
|
"github.com/go-chi/chi/v5/middleware"
|
2024-12-04 11:46:42 +00:00
|
|
|
|
2024-12-12 07:54:50 +00:00
|
|
|
"code.alt-gnome.ru/aides-infra/aides-repo-api/internal/config"
|
2024-12-12 13:27:07 +00:00
|
|
|
"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/internal/services/taskservice"
|
2024-12-04 11:46:42 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type Router struct {
|
2024-12-12 13:27:07 +00:00
|
|
|
config *config.Config
|
2024-12-04 11:46:42 +00:00
|
|
|
}
|
|
|
|
|
2024-12-12 13:27:07 +00:00
|
|
|
func New(config *config.Config) *Router {
|
|
|
|
return &Router{
|
|
|
|
config: config,
|
|
|
|
}
|
2024-12-04 11:46:42 +00:00
|
|
|
}
|
|
|
|
|
2024-12-12 13:27:07 +00:00
|
|
|
func (r *Router) Setup() *chi.Mux {
|
2024-12-04 11:46:42 +00:00
|
|
|
router := chi.NewRouter()
|
|
|
|
router.Use(middleware.Logger)
|
|
|
|
|
2024-12-12 13:27:07 +00:00
|
|
|
taskService := taskservice.New(
|
|
|
|
r.config,
|
|
|
|
)
|
2024-12-04 11:46:42 +00:00
|
|
|
|
2024-12-12 13:27:07 +00:00
|
|
|
taskController := taskcontroller.New(
|
|
|
|
r.config,
|
|
|
|
taskService,
|
|
|
|
)
|
2024-12-04 11:46:42 +00:00
|
|
|
|
2024-12-12 13:27:07 +00:00
|
|
|
router.Route("/task/{taskID}", func(cr chi.Router) {
|
|
|
|
cr.With(middlewares.CreateAuthGuard(r.config)).Post("/upload", taskController.Upload)
|
|
|
|
})
|
2024-12-04 11:46:42 +00:00
|
|
|
|
2024-12-12 13:27:07 +00:00
|
|
|
return router
|
2024-12-04 11:46:42 +00:00
|
|
|
}
|