quintodrome/controllers/ping.go

25 lines
562 B
Go
Raw Normal View History

2016-02-23 20:07:57 -09:00
package controllers
2016-02-23 20:29:27 -09:00
import (
"github.com/astaxie/beego"
"encoding/xml"
)
2016-02-23 20:07:57 -09:00
2016-02-23 20:29:27 -09:00
type PingResponse struct {
XMLName xml.Name `xml:"http://subsonic.org/restapi subsonic-response"`
Status string `xml:"status,attr"`
Version string `xml:"version,attr"`
2016-02-23 20:07:57 -09:00
}
2016-02-23 20:29:27 -09:00
type PingController struct{ beego.Controller }
2016-02-23 20:07:57 -09:00
// @router /rest/ping.view [get]
func (this *PingController) Get() {
2016-02-23 20:29:27 -09:00
response := &PingResponse{Status:"ok", Version: beego.AppConfig.String("apiversion")}
xmlBody, _ := xml.Marshal(response)
this.Ctx.Output.Body([]byte(xml.Header + string(xmlBody)))
2016-02-23 20:07:57 -09:00
}