http.go 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. package http
  2. import (
  3. "go-common/app/service/main/member/conf"
  4. "go-common/app/service/main/member/server/http/block"
  5. "go-common/app/service/main/member/service"
  6. "go-common/library/log"
  7. bm "go-common/library/net/http/blademaster"
  8. v "go-common/library/net/http/blademaster/middleware/verify"
  9. "net/http"
  10. )
  11. var (
  12. memberSvc *service.Service
  13. verify *v.Verify
  14. )
  15. // Init init http sever instance.
  16. func Init(c *conf.Config, s *service.Service) {
  17. verify = v.New(c.Verify)
  18. memberSvc = s
  19. engine := bm.DefaultServer(c.BM)
  20. setup(engine)
  21. block.Setup(memberSvc.BlockImpl(), engine, verify)
  22. if err := engine.Start(); err != nil {
  23. log.Error("http.Serve inner error(%v)", err)
  24. panic(err)
  25. }
  26. }
  27. func setup(e *bm.Engine) {
  28. e.Ping(ping)
  29. e.Register(register)
  30. mb := e.Group("/x/internal/member", verify.Verify)
  31. mb.POST("/sign/update", setSign)
  32. mb.POST("/name/update", setName)
  33. mb.POST("/rank/update", setRank)
  34. mb.POST("/birthday/update", setBirthday)
  35. mb.POST("/sex/update", setSex)
  36. mb.POST("/face/update", setFace)
  37. mb.POST("/base/update", setBase)
  38. mb.POST("/morals/update", updateMorals)
  39. mb.POST("/moral/update", updateMoral)
  40. mb.POST("/moral/undo", undoMoral)
  41. mb.GET("/moral", moral)
  42. mb.GET("/moral/log", moralLog)
  43. mb.GET("", member)
  44. mb.GET("/base", base)
  45. mb.GET("/batchBase", batchBase)
  46. mb.GET("/exp", exp)
  47. mb.GET("/level", level)
  48. mb.GET("/official", official)
  49. mb.POST("/exp/set", setExp)
  50. mb.POST("/exp/update", updateExp)
  51. mb.GET("/exp/log", explog)
  52. mb.GET("/exp/stat", stat)
  53. mb.GET("/cache/del", cacheDel)
  54. mb.POST("/property/review/add", addPropertyReview)
  55. // realname
  56. mb.GET("/realname/status", realnameStatus)
  57. mb.GET("/realname/info", realnameInfo)
  58. mb.POST("/realname/tel/capture", realnameTelCapture)
  59. mb.GET("/realname/tel/capture/check", realnameCheckTelCapture)
  60. mb.GET("/realname/apply/status", realnameApplyStatus)
  61. mb.POST("/realname/apply", realnameApply)
  62. mb.GET("/realname/adult", realnameAdult)
  63. mb.GET("/realname/check", realnameCheck)
  64. mb.GET("/realname/stripped/info", realnameStrippedInfo)
  65. mb.GET("/realname/mid/by/card", realnameMidByCard)
  66. }
  67. // ping check server ok.
  68. func ping(c *bm.Context) {
  69. if err := memberSvc.Ping(c); err != nil {
  70. log.Error("service ping error(%+v)", err)
  71. c.AbortWithStatus(http.StatusServiceUnavailable)
  72. }
  73. }
  74. func register(c *bm.Context) {
  75. c.JSON(nil, nil)
  76. }