Download REST API endpoints (#72)

* backend and frontend hotfixes, see message

Improved rendering on the frontend by cutting unecessary useStates.
Backend side, downloads now auto resume even on application kill.

* download rest api endpoints, general code refactor

* download request json mappings
This commit is contained in:
Marco
2023-07-31 08:30:09 +02:00
committed by GitHub
parent 68c829c40e
commit 8327d1e94c
22 changed files with 560 additions and 300 deletions

25
server/rest/container.go Normal file
View File

@@ -0,0 +1,25 @@
package rest
import (
"github.com/go-chi/chi/v5"
"github.com/marcopeocchi/yt-dlp-web-ui/server/internal"
middlewares "github.com/marcopeocchi/yt-dlp-web-ui/server/middleware"
)
func Container(db *internal.MemoryDB, mq *internal.MessageQueue) *Handler {
var (
service = ProvideService(db, mq)
handler = ProvideHandler(service)
)
return handler
}
func ApplyRouter(db *internal.MemoryDB, mq *internal.MessageQueue) func(chi.Router) {
h := Container(db, mq)
return func(r chi.Router) {
r.Use(middlewares.Authenticated)
r.Post("/exec", h.Exec())
r.Get("/running", h.Running())
}
}