ApiCtrl.go 559 B

1234567891011121314151617181920212223242526272829
  1. package BaseCtrl
  2. import (
  3. "forward-core/NetUtils"
  4. "github.com/astaxie/beego"
  5. "github.com/astaxie/beego/logs"
  6. )
  7. type ApiCtrl struct {
  8. beego.Controller
  9. }
  10. var apiAuth = beego.AppConfig.String("api.auth")
  11. func (c *ApiCtrl) Prepare() {
  12. reqUrl := c.Ctx.Request.RequestURI
  13. userIp := NetUtils.GetIP(&c.Controller)
  14. logs.Debug("执行Prepare,当前reqUrl:", reqUrl, " userIp:", userIp)
  15. //校验鉴权参数
  16. auth := c.GetString("auth")
  17. if auth != apiAuth {
  18. //logs.Error("apiAuth验证失败:", auth)
  19. //c.Ctx.Redirect(302, "/apiAuthFail")
  20. }
  21. }
粤ICP备19079148号