Implemented request validation in a filter

This commit is contained in:
Deluan
2016-02-24 20:21:51 -05:00
parent 93f115d8e4
commit ee04b72db1
6 changed files with 9 additions and 13 deletions
+7 -7
View File
@@ -1,16 +1,10 @@
// @APIVersion 1.0.0
// @Title beego Test API
// @Description beego has a very cool tools to autogenerate documents for your API
// @Contact astaxie@gmail.com
// @TermsOfServiceUrl http://beego.me/
// @License Apache 2.0
// @LicenseUrl http://www.apache.org/licenses/LICENSE-2.0.html
package routers
import (
"github.com/deluan/gosonic/controllers"
"github.com/astaxie/beego"
"github.com/astaxie/beego/context"
)
func init() {
@@ -19,4 +13,10 @@ func init() {
&controllers.GetLicenseController{},
&controllers.GetMusicFoldersController{},
)
var ValidateRequest = func(ctx *context.Context) {
controllers.Validate(&beego.Controller{Ctx: ctx})
}
beego.InsertFilter("/rest/*", beego.BeforeRouter, ValidateRequest)
}