platform.go 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. package http
  2. import (
  3. "strings"
  4. "go-common/library/ecode"
  5. bm "go-common/library/net/http/blademaster"
  6. )
  7. func searchProxyGet(c *bm.Context) {
  8. req := c.Request
  9. idx := strings.Index(req.URL.Path, "/x/admin/apm/platform/search/get/")
  10. if idx == -1 {
  11. c.JSON(nil, ecode.RequestErr)
  12. return
  13. }
  14. data, err := apmSvc.PlatformProxy(c, "GET", req.URL.Path[idx+len("/x/admin/apm/platform/search/get/"):], req.Form)
  15. if err != nil {
  16. c.JSON(nil, err)
  17. return
  18. }
  19. c.JSON(data, nil)
  20. }
  21. func searchProxyPost(c *bm.Context) {
  22. req := c.Request
  23. idx := strings.Index(req.URL.Path, "/x/admin/apm/platform/search/post/")
  24. if idx == -1 {
  25. c.JSON(nil, ecode.RequestErr)
  26. return
  27. }
  28. data, err := apmSvc.PlatformProxy(c, "POST", req.URL.Path[idx+len("/x/admin/apm/platform/search/post/"):], req.Form)
  29. if err != nil {
  30. c.JSON(nil, err)
  31. return
  32. }
  33. c.JSON(data, nil)
  34. }
  35. func replyProxyGet(c *bm.Context) {
  36. req := c.Request
  37. idx := strings.Index(req.URL.Path, "/x/admin/apm/platform/reply/get/")
  38. if idx == -1 {
  39. c.JSON(nil, ecode.RequestErr)
  40. return
  41. }
  42. data, err := apmSvc.PlatformProxy(c, "GET", req.URL.Path[idx+len("/x/admin/apm/platform/reply/get/"):], req.Form)
  43. if err != nil {
  44. c.JSON(nil, err)
  45. return
  46. }
  47. c.JSON(data, nil)
  48. }
  49. func replyProxyPost(c *bm.Context) {
  50. req := c.Request
  51. idx := strings.Index(req.URL.Path, "/x/admin/apm/platform/reply/post/")
  52. if idx == -1 {
  53. c.JSON(nil, ecode.RequestErr)
  54. return
  55. }
  56. data, err := apmSvc.PlatformProxy(c, "POST", req.URL.Path[idx+len("/x/admin/apm/platform/reply/post/"):], req.Form)
  57. if err != nil {
  58. c.JSON(nil, err)
  59. return
  60. }
  61. c.JSON(data, nil)
  62. }
  63. func tagProxyGet(c *bm.Context) {
  64. req := c.Request
  65. idx := strings.Index(req.URL.Path, "/x/admin/apm/platform/tag/get/")
  66. if idx == -1 {
  67. c.JSON(nil, ecode.RequestErr)
  68. return
  69. }
  70. data, err := apmSvc.PlatformProxy(c, "GET", req.URL.Path[idx+len("/x/admin/apm/platform/tag/get/"):], req.Form)
  71. if err != nil {
  72. c.JSON(nil, err)
  73. return
  74. }
  75. c.JSON(data, nil)
  76. }
  77. func tagProxyPost(c *bm.Context) {
  78. req := c.Request
  79. idx := strings.Index(req.URL.Path, "/x/admin/apm/platform/tag/post/")
  80. if idx == -1 {
  81. c.JSON(nil, ecode.RequestErr)
  82. return
  83. }
  84. data, err := apmSvc.PlatformProxy(c, "POST", req.URL.Path[idx+len("/x/admin/apm/platform/tag/post/"):], req.Form)
  85. if err != nil {
  86. c.JSON(nil, err)
  87. return
  88. }
  89. c.JSON(data, nil)
  90. }
  91. func bfsProxyGet(c *bm.Context) {
  92. req := c.Request
  93. idx := strings.Index(req.URL.Path, "/x/admin/apm/platform/bfs/get/")
  94. if idx == -1 {
  95. c.JSON(nil, ecode.RequestErr)
  96. return
  97. }
  98. data, err := apmSvc.PlatformProxy(c, "GET", req.URL.Path[idx+len("/x/admin/apm/platform/bfs/get/"):], req.Form)
  99. if err != nil {
  100. c.JSON(nil, err)
  101. return
  102. }
  103. c.JSON(data, nil)
  104. }
  105. func bfsProxyPost(c *bm.Context) {
  106. req := c.Request
  107. idx := strings.Index(req.URL.Path, "/x/admin/apm/platform/bfs/post/")
  108. if idx == -1 {
  109. c.JSON(nil, ecode.RequestErr)
  110. return
  111. }
  112. data, err := apmSvc.PlatformProxy(c, "POST", req.URL.Path[idx+len("/x/admin/apm/platform/bfs/post/"):], req.Form)
  113. if err != nil {
  114. c.JSON(nil, err)
  115. return
  116. }
  117. c.JSON(data, nil)
  118. }
  119. func replyFeedProxyGet(c *bm.Context) {
  120. req := c.Request
  121. idx := strings.Index(req.URL.Path, "/x/admin/apm/platform/reply/feed/get/")
  122. if idx == -1 {
  123. c.JSON(nil, ecode.RequestErr)
  124. return
  125. }
  126. data, err := apmSvc.PlatformProxy(c, "GET", req.URL.Path[idx+len("/x/admin/apm/platform/reply/feed/get/"):], req.Form)
  127. if err != nil {
  128. c.JSON(nil, err)
  129. return
  130. }
  131. c.JSON(data, nil)
  132. }
  133. func replyFeedProxyPost(c *bm.Context) {
  134. req := c.Request
  135. idx := strings.Index(req.URL.Path, "/x/admin/apm/platform/reply/feed/post/")
  136. if idx == -1 {
  137. c.JSON(nil, ecode.RequestErr)
  138. return
  139. }
  140. data, err := apmSvc.PlatformProxy(c, "POST", req.URL.Path[idx+len("/x/admin/apm/platform/reply/feed/post/"):], req.Form)
  141. if err != nil {
  142. c.JSON(nil, err)
  143. return
  144. }
  145. c.JSON(data, nil)
  146. }