From 107803e037de0abb66d77904ef05bc4d2ea2c710 Mon Sep 17 00:00:00 2001 From: Deluan Date: Tue, 9 Feb 2021 21:25:14 -0500 Subject: [PATCH] Update list of Not Implemented / Gone Subsonic API endpoints --- server/subsonic/api.go | 50 +++++++++++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 13 deletions(-) diff --git a/server/subsonic/api.go b/server/subsonic/api.go index cf89ee4fe..3b4039076 100644 --- a/server/subsonic/api.go +++ b/server/subsonic/api.go @@ -154,12 +154,21 @@ func (api *Router) routes() http.Handler { h(withPlayer, "download", c.Download) }) - // Deprecated/Out of scope endpoints - h410(r, "getChatMessages") - h410(r, "addChatMessage") - h410(r, "getVideos") - h410(r, "getVideoInfo") - h410(r, "getCaptions") + // Not Implemented (yet?) + h501(r, "getLyrics") + h501(r, "jukeboxControl") + h501(r, "getAlbumInfo", "getAlbumInfo2") + h501(r, "getShares", "createShare", "updateShare", "deleteShare") + h501(r, "getPodcasts", "getNewestPodcasts", "refreshPodcasts", "createPodcastChannel", "deletePodcastChannel", + "deletePodcastEpisode", "downloadPodcastEpisode") + h501(r, "getInternetRadioStations", "createInternetRadioStation", "updateInternetRadioStation", + "deleteInternetRadioStation") + h501(r, "createUser", "updateUser", "deleteUser", "changePassword") + + // Deprecated/Won't implement/Out of scope endpoints + h410(r, "search") + h410(r, "getChatMessages", "addChatMessage") + h410(r, "getVideos", "getVideoInfo", "getCaptions", "hls") return r } @@ -188,14 +197,29 @@ func h(r chi.Router, path string, f handler) { r.HandleFunc("/"+path+".view", handle) } -// Add a handler that returns 410 - Gone. Used to signal that an endpoint will not be implemented -func h410(r chi.Router, path string) { - handle := func(w http.ResponseWriter, r *http.Request) { - w.WriteHeader(410) - _, _ = w.Write([]byte("This endpoint will not be implemented")) +// Add a handler that returns 510 - Not implemented. Used to signal that an endpoint is not implemented yet +func h501(r *chi.Mux, paths ...string) { + for _, path := range paths { + handle := func(w http.ResponseWriter, r *http.Request) { + w.Header().Add("Cache-Control", "no-cache") + w.WriteHeader(510) + _, _ = w.Write([]byte("This endpoint is not implemented, but may be in future releases")) + } + r.HandleFunc("/"+path, handle) + r.HandleFunc("/"+path+".view", handle) + } +} + +// Add a handler that returns 410 - Gone. Used to signal that an endpoint will not be implemented +func h410(r chi.Router, paths ...string) { + for _, path := range paths { + handle := func(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(410) + _, _ = w.Write([]byte("This endpoint will not be implemented")) + } + r.HandleFunc("/"+path, handle) + r.HandleFunc("/"+path+".view", handle) } - r.HandleFunc("/"+path, handle) - r.HandleFunc("/"+path+".view", handle) } func sendError(w http.ResponseWriter, r *http.Request, err error) {