mirror of
https://github.com/marcopiovanello/yt-dlp-web-ui.git
synced 2026-07-25 06:54:30 +00:00
143cc28a97
* refactoring-1 introduced pipelines and abstracted download process.go in Downloader interface * migrated to boltdb from sqlite + session files * refactoring: config struct & pipelines * added js runtime for yt-dlp * updated dockerfile * added external js runtime, metadata scraping refactor * updated Dockerfile * fixed env propagation in docker * updated package name to v4 * updated readme and cd
39 lines
786 B
Go
39 lines
786 B
Go
package rest
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
|
|
"github.com/marcopiovanello/yt-dlp-web-ui/v4/server/status/domain"
|
|
)
|
|
|
|
type RestHandler struct {
|
|
service domain.Service
|
|
}
|
|
|
|
// Status implements domain.RestHandler.
|
|
func (h *RestHandler) Status() http.HandlerFunc {
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
|
defer r.Body.Close()
|
|
|
|
w.Header().Set("Content-Type", "application/json")
|
|
|
|
status, err := h.service.Status(r.Context())
|
|
if err != nil {
|
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
return
|
|
}
|
|
|
|
if err := json.NewEncoder(w).Encode(status); err != nil {
|
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
return
|
|
}
|
|
}
|
|
}
|
|
|
|
func New(service domain.Service) domain.RestHandler {
|
|
return &RestHandler{
|
|
service: service,
|
|
}
|
|
}
|