Moved responses package and started getMusicFolders endpoint

This commit is contained in:
Deluan
2016-02-24 15:29:19 -05:00
parent c6dfea51ff
commit c8b7695b09
7 changed files with 40 additions and 3 deletions
+25
View File
@@ -0,0 +1,25 @@
package responses
import (
"encoding/xml"
"github.com/astaxie/beego"
)
type Subsonic struct {
XMLName xml.Name `xml:"http://subsonic.org/restapi subsonic-response"`
Status string `xml:"status,attr"`
Version string `xml:"version,attr"`
Body []byte `xml:",innerxml"`
}
func NewEmpty() Subsonic {
return Subsonic{Status: "ok", Version: beego.AppConfig.String("apiversion")}
}
func NewXML(body interface{}) []byte {
response := NewEmpty()
xmlBody, _ := xml.Marshal(body)
response.Body = xmlBody
xmlResponse, _ := xml.Marshal(response)
return []byte(xml.Header + string(xmlResponse))
}