35 lines
814 B
Go
35 lines
814 B
Go
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},
|
|
})
|
|
}
|