mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-04 21:17:37 +03:00
Added a MainController
This commit is contained in:
parent
a4e7d63377
commit
1e842ccfdf
4 changed files with 37 additions and 1 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -2,4 +2,5 @@ tests/**/commentsRouter_*.go
|
||||||
lastupdate.tmp
|
lastupdate.tmp
|
||||||
gosonic
|
gosonic
|
||||||
iTunes Music Library.xml
|
iTunes Music Library.xml
|
||||||
gosonic.index
|
gosonic.index
|
||||||
|
static/Jamstash
|
26
controllers/main.go
Normal file
26
controllers/main.go
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
package controllers
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/astaxie/beego"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
type MainController struct{ beego.Controller }
|
||||||
|
|
||||||
|
|
||||||
|
// @router / [get]
|
||||||
|
func (this *MainController) Get() {
|
||||||
|
this.Ctx.Redirect(302, "/static/Jamstash/")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func (this *MainController) Error404() {
|
||||||
|
if beego.BConfig.RunMode == beego.DEV || beego.BConfig.Log.AccessLogs {
|
||||||
|
r := this.Ctx.Request
|
||||||
|
devInfo := fmt.Sprintf(" | %-10s | %-40s | %-16s | %-10s |", r.Method, r.URL.Path, " ", "notmatch")
|
||||||
|
if beego.DefaultAccessLogFilter == nil || !beego.DefaultAccessLogFilter.Filter(this.Ctx) {
|
||||||
|
beego.Warn(devInfo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.CustomAbort(404, "Error 404")
|
||||||
|
}
|
|
@ -20,6 +20,13 @@ func init() {
|
||||||
[]string{"get"},
|
[]string{"get"},
|
||||||
nil})
|
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.GlobalControllerRouter["github.com/deluan/gosonic/controllers:ObjectController"] = append(beego.GlobalControllerRouter["github.com/deluan/gosonic/controllers:ObjectController"],
|
||||||
beego.ControllerComments{
|
beego.ControllerComments{
|
||||||
"Post",
|
"Post",
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
beego.Include(
|
beego.Include(
|
||||||
|
&controllers.MainController{},
|
||||||
&controllers.PingController{},
|
&controllers.PingController{},
|
||||||
&controllers.GetLicenseController{},
|
&controllers.GetLicenseController{},
|
||||||
&controllers.GetMusicFoldersController{},
|
&controllers.GetMusicFoldersController{},
|
||||||
|
@ -19,4 +20,5 @@ func init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
beego.InsertFilter("/rest/*", beego.BeforeRouter, ValidateRequest)
|
beego.InsertFilter("/rest/*", beego.BeforeRouter, ValidateRequest)
|
||||||
|
beego.ErrorController(&controllers.MainController{})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue