diff --git a/internal/subsonic/handlers.go b/internal/subsonic/handlers.go new file mode 100644 index 00000000..2a210986 --- /dev/null +++ b/internal/subsonic/handlers.go @@ -0,0 +1,34 @@ +package subsonic + +import ( + "encoding/xml" + "net/http" +) + +// PingResponse is envelope-only; clients treat any ok response as success. +type PingResponse struct { + Envelope +} + +func handlePing(w http.ResponseWriter, r *http.Request) { + Write(w, r, PingResponse{Envelope: NewEnvelope("ok")}) +} + +// LicenseResponse reports the (always-valid) self-hosted license. Many +// Subsonic clients refuse to stream until this endpoint returns valid=true. +type LicenseResponse struct { + Envelope + License License `json:"license" xml:"license"` +} + +type License struct { + XMLName xml.Name `json:"-" xml:"license"` + Valid bool `json:"valid" xml:"valid,attr"` +} + +func handleGetLicense(w http.ResponseWriter, r *http.Request) { + Write(w, r, LicenseResponse{ + Envelope: NewEnvelope("ok"), + License: License{Valid: true}, + }) +}