aides-repo-api/internal/router/router.go

41 lines
899 B
Go

package router
import (
"github.com/go-chi/chi/v5"
"github.com/go-chi/chi/v5/middleware"
"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/internal/services/taskservice"
)
type Router struct {
config *config.Config
}
func New(config *config.Config) *Router {
return &Router{
config: config,
}
}
func (r *Router) Setup() *chi.Mux {
router := chi.NewRouter()
router.Use(middleware.Logger)
taskService := taskservice.New(
r.config,
)
taskController := taskcontroller.New(
r.config,
taskService,
)
router.Route("/task/{taskID}", func(cr chi.Router) {
cr.With(middlewares.CreateAuthGuard(r.config)).Post("/upload", taskController.Upload)
})
return router
}