From 2a75fc668700c818852babca4250407a2b16e89e Mon Sep 17 00:00:00 2001 From: bvandeusen Date: Sun, 19 Apr 2026 17:38:34 +0000 Subject: [PATCH] feat(subsonic): ping.view + getLicense.view handlers --- internal/subsonic/handlers.go | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 internal/subsonic/handlers.go 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}, + }) +}