Files
yt-dlp-web-ui/server/status/rest/handler.go
T
Marco Piovanello 143cc28a97 Server v4 (#370)
* 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
2026-06-29 19:01:53 +02:00

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,
}
}