base_not_auth.go 962 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package controllers
  2. import (
  3. "fmt"
  4. "hongze/hongze_mobile_admin/utils"
  5. "net/url"
  6. )
  7. //不需要授权的基类
  8. type BaseNotAuth struct {
  9. BaseCommon
  10. }
  11. func (c *BaseNotAuth) Prepare() {
  12. var requestBody string
  13. method := c.Ctx.Input.Method()
  14. if method == "GET" {
  15. requestBody = c.Ctx.Request.RequestURI
  16. } else {
  17. requestBody, _ = url.QueryUnescape(string(c.Ctx.Input.RequestBody))
  18. }
  19. fmt.Println("requestBody:", requestBody)
  20. ip := c.Ctx.Input.IP()
  21. fmt.Println("ip:", ip)
  22. //apiLog.Println("请求地址:", c.Ctx.Input.URI(), "RequestBody:", requestBody, "IP:", ip)
  23. authorization := c.Ctx.Input.Header("Authorization")
  24. if authorization == "" {
  25. cookie := c.Ctx.GetCookie("rddp_access_token")
  26. utils.FileLog.Info("authorization:%s,cookie:%s", authorization, cookie)
  27. authorization = cookie
  28. }
  29. uri := c.Ctx.Input.URI()
  30. utils.FileLog.Info("URI:%s", uri)
  31. //if strings.Contains(uri, "/h5adminapi/wechat/login") {
  32. // authorization = ""
  33. //}
  34. }