Add yt-downloader
This commit is contained in:
@@ -9,8 +9,7 @@ import (
|
||||
)
|
||||
|
||||
type requestDownloadRequest struct {
|
||||
Provider string `json:"provider"`
|
||||
Link string `json:"link"`
|
||||
Link string `json:"link"`
|
||||
}
|
||||
|
||||
type requestDownloadResponse struct {
|
||||
@@ -22,7 +21,7 @@ func (_ requestDownloadResponse) Render(_ http.ResponseWriter, _ *http.Request)
|
||||
}
|
||||
|
||||
func (dr *requestDownloadRequest) Bind(r *http.Request) error {
|
||||
if dr.Link == "" || dr.Provider == "" {
|
||||
if dr.Link == "" {
|
||||
return errors.New("missing required download request field")
|
||||
}
|
||||
|
||||
@@ -36,7 +35,7 @@ func (a *api) requestDownload(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
download, err := a.drService.Schedule(data.Provider, data.Link)
|
||||
download, err := a.drService.Schedule(data.Link)
|
||||
if err != nil {
|
||||
_ = render.Render(w, r, responses.ErrInvalidRequest(err))
|
||||
return
|
||||
|
@@ -1,15 +1,15 @@
|
||||
package download
|
||||
|
||||
import (
|
||||
"downloader/internal/core/ports/download_request"
|
||||
"downloader/internal/core/services/download"
|
||||
"github.com/go-chi/chi"
|
||||
)
|
||||
|
||||
type api struct {
|
||||
drService download_request.Service
|
||||
drService download.Service
|
||||
}
|
||||
|
||||
func New(service download_request.Service) *api {
|
||||
func New(service download.Service) *api {
|
||||
return &api{drService: service}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user