42 lines
1.1 KiB
Go
42 lines
1.1 KiB
Go
package rest
|
|
|
|
import (
|
|
"github.com/go-chi/chi/v5"
|
|
"github.com/marcopiovanello/yt-dlp-web-ui/v3/server/config"
|
|
middlewares "github.com/marcopiovanello/yt-dlp-web-ui/v3/server/middleware"
|
|
"github.com/marcopiovanello/yt-dlp-web-ui/v3/server/openid"
|
|
)
|
|
|
|
func Container(args *ContainerArgs) *Handler {
|
|
var (
|
|
service = ProvideService(args)
|
|
handler = ProvideHandler(service)
|
|
)
|
|
return handler
|
|
}
|
|
|
|
func ApplyRouter(args *ContainerArgs) func(chi.Router) {
|
|
h := Container(args)
|
|
|
|
return func(r chi.Router) {
|
|
if config.Instance().RequireAuth {
|
|
r.Use(middlewares.Authenticated)
|
|
}
|
|
if config.Instance().UseOpenId {
|
|
r.Use(openid.Middleware)
|
|
}
|
|
r.Post("/exec", h.Exec())
|
|
r.Post("/execPlaylist", h.ExecPlaylist())
|
|
r.Post("/execLivestream", h.ExecLivestream())
|
|
r.Get("/running", h.Running())
|
|
r.Get("/version", h.GetVersion())
|
|
r.Get("/cookies", h.GetCookies())
|
|
r.Post("/cookies", h.SetCookies())
|
|
r.Delete("/cookies", h.DeleteCookies())
|
|
r.Post("/template", h.AddTemplate())
|
|
r.Patch("/template", h.UpdateTemplate())
|
|
r.Get("/template/all", h.GetTemplates())
|
|
r.Delete("/template/{id}", h.DeleteTemplate())
|
|
}
|
|
}
|