Moved responses package and started getMusicFolders endpoint
This commit is contained in:
@@ -2,7 +2,7 @@ package controllers
|
||||
|
||||
import (
|
||||
"github.com/astaxie/beego"
|
||||
"github.com/deluan/gosonic/responses"
|
||||
"github.com/deluan/gosonic/controllers/responses"
|
||||
)
|
||||
|
||||
type GetLicenseController struct{ beego.Controller }
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
package controllers
|
||||
+1
-1
@@ -3,7 +3,7 @@ package controllers
|
||||
import (
|
||||
"github.com/astaxie/beego"
|
||||
"encoding/xml"
|
||||
"github.com/deluan/gosonic/responses"
|
||||
"github.com/deluan/gosonic/controllers/responses"
|
||||
)
|
||||
|
||||
type PingController struct{ beego.Controller }
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
package responses
|
||||
|
||||
import "encoding/xml"
|
||||
|
||||
type License struct {
|
||||
XMLName xml.Name `xml:"license"`
|
||||
Valid bool `xml:"valid,attr"`
|
||||
}
|
||||
@@ -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))
|
||||
}
|
||||
Reference in New Issue
Block a user