diff --git a/cmd/dwellin-radiodj/main.go b/cmd/dwellin-radiodj/main.go index ff263f7..b36b701 100644 --- a/cmd/dwellin-radiodj/main.go +++ b/cmd/dwellin-radiodj/main.go @@ -54,7 +54,7 @@ func main() { s.Handler(http.MethodGet, "/", djh.PlaylistNext) s = r.Sub("/song") - s.Handler(http.MethodGet, "/", http.NotFound) + s.Handler(http.MethodGet, "/", djh.Song) srv := ihttp.NewHttpServer(r) diff --git a/internal/http/dj_handlers.go b/internal/http/dj_handlers.go index 2912794..75d6709 100644 --- a/internal/http/dj_handlers.go +++ b/internal/http/dj_handlers.go @@ -2,6 +2,7 @@ package http import ( "dwelling-radio/internal/radio" + "encoding/json" "fmt" "log" "net/http" @@ -47,3 +48,15 @@ func (dj *DJHandlers) PlaylistNext(w http.ResponseWriter, _ *http.Request) { } fmt.Fprint(w, nxt) } + +func (dj *DJHandlers) Song(w http.ResponseWriter, r *http.Request) { + isList := r.URL.Query().Has("list") + w.Header().Add("Content-Type", "application/json") + if isList { + // TODO + json.NewEncoder(w).Encode("") + } else { + // TODO + json.NewEncoder(w).Encode("") + } +}