web_internal.go 518 B

12345678910111213141516171819202122232425262728
  1. package http
  2. import (
  3. "strconv"
  4. "go-common/library/log"
  5. "go-common/library/net/http/blademaster"
  6. )
  7. // setContextMid 把form中的mid写入context中,用以调用interface的http接口
  8. func setContextMid(c *blademaster.Context) {
  9. var _, ok = c.Get("mid")
  10. if ok {
  11. return
  12. }
  13. var midstr = c.Request.Form.Get("mid")
  14. if midstr == "" {
  15. return
  16. }
  17. var mid, err = strconv.ParseInt(midstr, 10, 64)
  18. if err != nil {
  19. log.Error("parse mid fail, midstr=%s, err=%v", midstr, err)
  20. return
  21. }
  22. c.Set("mid", mid)
  23. }