Files
2020-12-01 21:19:37 +08:00

29 lines
559 B
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package BaseCtrl
import (
"forward-core/NetUtils"
"github.com/astaxie/beego"
"github.com/astaxie/beego/logs"
)
type ApiCtrl struct {
beego.Controller
}
var apiAuth = beego.AppConfig.String("api.auth")
func (c *ApiCtrl) Prepare() {
reqUrl := c.Ctx.Request.RequestURI
userIp := NetUtils.GetIP(&c.Controller)
logs.Debug("执行Prepare,当前reqUrl", reqUrl, " userIp:", userIp)
//校验鉴权参数
auth := c.GetString("auth")
if auth != apiAuth {
//logs.Error("apiAuth验证失败:", auth)
//c.Ctx.Redirect(302, "/apiAuthFail")
}
}