Better Ping implementation
This commit is contained in:
+13
-4
@@ -1,14 +1,23 @@
|
||||
package controllers
|
||||
|
||||
import "github.com/astaxie/beego"
|
||||
import (
|
||||
"github.com/astaxie/beego"
|
||||
"encoding/xml"
|
||||
)
|
||||
|
||||
type PingController struct {
|
||||
beego.Controller
|
||||
type PingResponse struct {
|
||||
XMLName xml.Name `xml:"http://subsonic.org/restapi subsonic-response"`
|
||||
Status string `xml:"status,attr"`
|
||||
Version string `xml:"version,attr"`
|
||||
}
|
||||
|
||||
type PingController struct{ beego.Controller }
|
||||
|
||||
// @router /rest/ping.view [get]
|
||||
func (this *PingController) Get() {
|
||||
this.Ctx.WriteString("<subsonic-response xmlns=\"http://subsonic.org/restapi\" status=\"ok\" version=\"1.0.0\"></subsonic-response>")
|
||||
response := &PingResponse{Status:"ok", Version: beego.AppConfig.String("apiversion")}
|
||||
xmlBody, _ := xml.Marshal(response)
|
||||
this.Ctx.Output.Body([]byte(xml.Header + string(xmlBody)))
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user