ip.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. package http
  2. import (
  3. "strings"
  4. "go-common/library/ecode"
  5. bm "go-common/library/net/http/blademaster"
  6. )
  7. // info ip info.
  8. func info(c *bm.Context) {
  9. var (
  10. ip string
  11. query = c.Request.Form
  12. )
  13. if ip = query.Get("ip"); ip == "" {
  14. c.JSON(nil, ecode.RequestErr)
  15. return
  16. }
  17. c.JSON(svr.Info(c, ip))
  18. }
  19. // infos ip info.
  20. func infos(c *bm.Context) {
  21. var (
  22. ips string
  23. query = c.Request.Form
  24. )
  25. if ips = query.Get("ips"); ips == "" {
  26. c.JSON(nil, ecode.RequestErr)
  27. return
  28. }
  29. c.JSON(svr.Infos(c, strings.Split(ips, ",")))
  30. }
  31. // infoComplete get whole ip info.
  32. func infoComplete(c *bm.Context) {
  33. var (
  34. ip string
  35. query = c.Request.Form
  36. )
  37. if ip = query.Get("ip"); ip == "" {
  38. c.JSON(nil, ecode.RequestErr)
  39. return
  40. }
  41. c.JSON(svr.InfoComplete(c, ip))
  42. }
  43. // infosComplete get whole ip infos.
  44. func infosComplete(c *bm.Context) {
  45. var (
  46. ips string
  47. query = c.Request.Form
  48. )
  49. if ips = query.Get("ips"); ips == "" {
  50. c.JSON(nil, ecode.RequestErr)
  51. return
  52. }
  53. c.JSON(svr.InfosComplete(c, strings.Split(ips, ",")))
  54. }
  55. // anonym ip info.
  56. func anonym(c *bm.Context) {
  57. var (
  58. ip string
  59. query = c.Request.Form
  60. )
  61. if ip = query.Get("ip"); ip == "" {
  62. c.JSON(nil, ecode.RequestErr)
  63. return
  64. }
  65. c.JSON(svr.Anonym(ip))
  66. }