read.go 643 B

1234567891011121314151617181920212223242526272829303132
  1. package http
  2. import (
  3. "strconv"
  4. "time"
  5. "go-common/library/ecode"
  6. bm "go-common/library/net/http/blademaster"
  7. "go-common/library/net/metadata"
  8. )
  9. func readPing(c *bm.Context) {
  10. var (
  11. buvid = buvid(c)
  12. aid int64
  13. mid int64
  14. ip = metadata.String(c, metadata.RemoteIP)
  15. cur = time.Now().Unix()
  16. source = c.Request.Form.Get("source")
  17. err error
  18. )
  19. if aid, err = strconv.ParseInt(c.Request.Form.Get("aid"), 10, 64); err != nil {
  20. c.JSON(nil, ecode.RequestErr)
  21. return
  22. }
  23. if i, ok := c.Get("mid"); ok {
  24. mid = i.(int64)
  25. } else {
  26. mid = 0
  27. }
  28. c.JSON(nil, artSrv.ReadPing(c, buvid, aid, mid, ip, cur, source))
  29. }