beego.go 777 字节
package appsvr

import (
	"github.com/astaxie/beego"
	. "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/log"
	"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/port/appsvr/middleware"
	_ "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/port/appsvr/routers"
	"time"
)

func init() {
	beego.InsertFilter("/*", beego.BeforeExec, middleware.CreateRequestBodyFilter())

	beego.InsertFilter("/v1/*", beego.BeforeExec, middleware.CheckJWTToken)
	beego.InsertFilter("/v2/*", beego.BeforeExec, middleware.CheckJWTToken)

	beego.InsertFilter("/*", beego.BeforeExec, middleware.CreateRequstLogFilter(Logger))
	beego.InsertFilter("/*", beego.AfterExec, middleware.CreateResponseLogFilter(Logger), false)

	// 默认时区设置
	timeLocal, _ := time.LoadLocation("Asia/Chongqing")
	time.Local = timeLocal
}