open.go 805 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package http
  2. import (
  3. "strings"
  4. "go-common/library/ecode"
  5. bm "go-common/library/net/http/blademaster"
  6. )
  7. func openProxyGet(c *bm.Context) {
  8. req := c.Request
  9. idx := strings.Index(req.URL.Path, "/x/admin/apm/open/get/")
  10. if idx == -1 {
  11. c.JSON(nil, ecode.RequestErr)
  12. return
  13. }
  14. data, err := apmSvc.OpenProxy(c, "GET", req.URL.Path[idx+len("/x/admin/apm/open/get/"):], req.Form)
  15. if err != nil {
  16. c.JSON(nil, err)
  17. return
  18. }
  19. c.JSON(data, nil)
  20. }
  21. func openProxyPost(c *bm.Context) {
  22. req := c.Request
  23. idx := strings.Index(req.URL.Path, "/x/admin/apm/open/post/")
  24. if idx == -1 {
  25. c.JSON(nil, ecode.RequestErr)
  26. return
  27. }
  28. data, err := apmSvc.OpenProxy(c, "POST", req.URL.Path[idx+len("/x/admin/apm/open/post/"):], req.Form)
  29. if err != nil {
  30. c.JSON(nil, err)
  31. return
  32. }
  33. c.JSON(data, nil)
  34. }