mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-04 04:57:37 +03:00
Moved Rest controllers to 'api' package. Also removed annotation routes
This commit is contained in:
parent
543e195744
commit
39757f884a
14 changed files with 20 additions and 143 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,4 +1,3 @@
|
|||
tests/**/commentsRouter_*.go
|
||||
lastupdate.tmp
|
||||
gosonic
|
||||
iTunes Music Library.xml
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
package controllers
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/astaxie/beego"
|
||||
"github.com/deluan/gosonic/controllers/responses"
|
||||
"github.com/deluan/gosonic/api/responses"
|
||||
)
|
||||
|
||||
type GetLicenseController struct{ beego.Controller }
|
||||
|
||||
// @router /rest/getLicense.view [get]
|
||||
func (this *GetLicenseController) Get() {
|
||||
response := responses.NewXML(&responses.License{Valid: true})
|
||||
this.Ctx.Output.Body(response)
|
|
@ -1,14 +1,13 @@
|
|||
package controllers
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/astaxie/beego"
|
||||
"github.com/deluan/gosonic/controllers/responses"
|
||||
"github.com/deluan/gosonic/api/responses"
|
||||
"github.com/deluan/gosonic/repositories"
|
||||
)
|
||||
|
||||
type GetMusicFoldersController struct{ beego.Controller }
|
||||
|
||||
// @router /rest/getMusicFolders.view [get]
|
||||
func (this *GetMusicFoldersController) Get() {
|
||||
repository := new(repositories.MediaFolderRepository)
|
||||
mediaFolderList, _ := repository.GetAll()
|
|
@ -1,14 +1,13 @@
|
|||
package controllers
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/astaxie/beego"
|
||||
"encoding/xml"
|
||||
"github.com/deluan/gosonic/controllers/responses"
|
||||
"github.com/deluan/gosonic/api/responses"
|
||||
)
|
||||
|
||||
type PingController struct{ beego.Controller }
|
||||
|
||||
// @router /rest/ping.view [get]
|
||||
func (this *PingController) Get() {
|
||||
response := responses.NewEmpty()
|
||||
xmlBody, _ := xml.Marshal(response)
|
|
@ -1,8 +1,8 @@
|
|||
package controllers
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/astaxie/beego"
|
||||
"github.com/deluan/gosonic/controllers/responses"
|
||||
"github.com/deluan/gosonic/api/responses"
|
||||
)
|
||||
|
||||
type ControllerInterface interface {
|
|
@ -8,7 +8,6 @@ import (
|
|||
type MainController struct{ beego.Controller }
|
||||
|
||||
|
||||
// @router / [get]
|
||||
func (this *MainController) Get() {
|
||||
this.Ctx.Redirect(302, "/static/Jamstash/")
|
||||
}
|
||||
|
|
|
@ -1,121 +0,0 @@
|
|||
package routers
|
||||
|
||||
import (
|
||||
"github.com/astaxie/beego"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
||||
beego.GlobalControllerRouter["github.com/deluan/gosonic/controllers:GetLicenseController"] = append(beego.GlobalControllerRouter["github.com/deluan/gosonic/controllers:GetLicenseController"],
|
||||
beego.ControllerComments{
|
||||
"Get",
|
||||
`/rest/getLicense.view`,
|
||||
[]string{"get"},
|
||||
nil})
|
||||
|
||||
beego.GlobalControllerRouter["github.com/deluan/gosonic/controllers:GetMusicFoldersController"] = append(beego.GlobalControllerRouter["github.com/deluan/gosonic/controllers:GetMusicFoldersController"],
|
||||
beego.ControllerComments{
|
||||
"Get",
|
||||
`/rest/getMusicFolders.view`,
|
||||
[]string{"get"},
|
||||
nil})
|
||||
|
||||
beego.GlobalControllerRouter["github.com/deluan/gosonic/controllers:MainController"] = append(beego.GlobalControllerRouter["github.com/deluan/gosonic/controllers:MainController"],
|
||||
beego.ControllerComments{
|
||||
"Get",
|
||||
`/`,
|
||||
[]string{"get"},
|
||||
nil})
|
||||
|
||||
beego.GlobalControllerRouter["github.com/deluan/gosonic/controllers:ObjectController"] = append(beego.GlobalControllerRouter["github.com/deluan/gosonic/controllers:ObjectController"],
|
||||
beego.ControllerComments{
|
||||
"Post",
|
||||
`/`,
|
||||
[]string{"post"},
|
||||
nil})
|
||||
|
||||
beego.GlobalControllerRouter["github.com/deluan/gosonic/controllers:ObjectController"] = append(beego.GlobalControllerRouter["github.com/deluan/gosonic/controllers:ObjectController"],
|
||||
beego.ControllerComments{
|
||||
"Get",
|
||||
`/:objectId`,
|
||||
[]string{"get"},
|
||||
nil})
|
||||
|
||||
beego.GlobalControllerRouter["github.com/deluan/gosonic/controllers:ObjectController"] = append(beego.GlobalControllerRouter["github.com/deluan/gosonic/controllers:ObjectController"],
|
||||
beego.ControllerComments{
|
||||
"GetAll",
|
||||
`/`,
|
||||
[]string{"get"},
|
||||
nil})
|
||||
|
||||
beego.GlobalControllerRouter["github.com/deluan/gosonic/controllers:ObjectController"] = append(beego.GlobalControllerRouter["github.com/deluan/gosonic/controllers:ObjectController"],
|
||||
beego.ControllerComments{
|
||||
"Put",
|
||||
`/:objectId`,
|
||||
[]string{"put"},
|
||||
nil})
|
||||
|
||||
beego.GlobalControllerRouter["github.com/deluan/gosonic/controllers:ObjectController"] = append(beego.GlobalControllerRouter["github.com/deluan/gosonic/controllers:ObjectController"],
|
||||
beego.ControllerComments{
|
||||
"Delete",
|
||||
`/:objectId`,
|
||||
[]string{"delete"},
|
||||
nil})
|
||||
|
||||
beego.GlobalControllerRouter["github.com/deluan/gosonic/controllers:PingController"] = append(beego.GlobalControllerRouter["github.com/deluan/gosonic/controllers:PingController"],
|
||||
beego.ControllerComments{
|
||||
"Get",
|
||||
`/rest/ping.view`,
|
||||
[]string{"get"},
|
||||
nil})
|
||||
|
||||
beego.GlobalControllerRouter["github.com/deluan/gosonic/controllers:UserController"] = append(beego.GlobalControllerRouter["github.com/deluan/gosonic/controllers:UserController"],
|
||||
beego.ControllerComments{
|
||||
"Post",
|
||||
`/`,
|
||||
[]string{"post"},
|
||||
nil})
|
||||
|
||||
beego.GlobalControllerRouter["github.com/deluan/gosonic/controllers:UserController"] = append(beego.GlobalControllerRouter["github.com/deluan/gosonic/controllers:UserController"],
|
||||
beego.ControllerComments{
|
||||
"GetAll",
|
||||
`/`,
|
||||
[]string{"get"},
|
||||
nil})
|
||||
|
||||
beego.GlobalControllerRouter["github.com/deluan/gosonic/controllers:UserController"] = append(beego.GlobalControllerRouter["github.com/deluan/gosonic/controllers:UserController"],
|
||||
beego.ControllerComments{
|
||||
"Get",
|
||||
`/:uid`,
|
||||
[]string{"get"},
|
||||
nil})
|
||||
|
||||
beego.GlobalControllerRouter["github.com/deluan/gosonic/controllers:UserController"] = append(beego.GlobalControllerRouter["github.com/deluan/gosonic/controllers:UserController"],
|
||||
beego.ControllerComments{
|
||||
"Put",
|
||||
`/:uid`,
|
||||
[]string{"put"},
|
||||
nil})
|
||||
|
||||
beego.GlobalControllerRouter["github.com/deluan/gosonic/controllers:UserController"] = append(beego.GlobalControllerRouter["github.com/deluan/gosonic/controllers:UserController"],
|
||||
beego.ControllerComments{
|
||||
"Delete",
|
||||
`/:uid`,
|
||||
[]string{"delete"},
|
||||
nil})
|
||||
|
||||
beego.GlobalControllerRouter["github.com/deluan/gosonic/controllers:UserController"] = append(beego.GlobalControllerRouter["github.com/deluan/gosonic/controllers:UserController"],
|
||||
beego.ControllerComments{
|
||||
"Login",
|
||||
`/login`,
|
||||
[]string{"get"},
|
||||
nil})
|
||||
|
||||
beego.GlobalControllerRouter["github.com/deluan/gosonic/controllers:UserController"] = append(beego.GlobalControllerRouter["github.com/deluan/gosonic/controllers:UserController"],
|
||||
beego.ControllerComments{
|
||||
"Logout",
|
||||
`/logout`,
|
||||
[]string{"get"},
|
||||
nil})
|
||||
|
||||
}
|
|
@ -1,22 +1,25 @@
|
|||
package routers
|
||||
|
||||
import (
|
||||
"github.com/deluan/gosonic/controllers"
|
||||
"github.com/deluan/gosonic/api"
|
||||
|
||||
"github.com/astaxie/beego"
|
||||
"github.com/astaxie/beego/context"
|
||||
"github.com/deluan/gosonic/controllers"
|
||||
)
|
||||
|
||||
func init() {
|
||||
beego.Include(
|
||||
&controllers.MainController{},
|
||||
&controllers.PingController{},
|
||||
&controllers.GetLicenseController{},
|
||||
&controllers.GetMusicFoldersController{},
|
||||
ns := beego.NewNamespace("/rest",
|
||||
beego.NSRouter("/ping.view", &api.PingController{}),
|
||||
beego.NSRouter("/getLicense.view", &api.GetLicenseController{}),
|
||||
beego.NSRouter("/getMusicFolders.view", &api.GetMusicFoldersController{}),
|
||||
)
|
||||
beego.AddNamespace(ns)
|
||||
|
||||
beego.Router("/", &controllers.MainController{})
|
||||
|
||||
var ValidateRequest = func(ctx *context.Context) {
|
||||
controllers.Validate(&beego.Controller{Ctx: ctx})
|
||||
api.Validate(&beego.Controller{Ctx: ctx})
|
||||
}
|
||||
|
||||
beego.InsertFilter("/rest/*", beego.BeforeRouter, ValidateRequest)
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
"encoding/xml"
|
||||
_ "github.com/deluan/gosonic/routers"
|
||||
. "github.com/smartystreets/goconvey/convey"
|
||||
"github.com/deluan/gosonic/controllers/responses"
|
||||
"github.com/deluan/gosonic/api/responses"
|
||||
. "github.com/deluan/gosonic/tests"
|
||||
)
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
_ "github.com/deluan/gosonic/routers"
|
||||
. "github.com/deluan/gosonic/tests"
|
||||
. "github.com/smartystreets/goconvey/convey"
|
||||
"github.com/deluan/gosonic/controllers/responses"
|
||||
"github.com/deluan/gosonic/api/responses"
|
||||
)
|
||||
|
||||
func TestCheckParams(t *testing.T) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue