server.go 714 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package http
  2. import (
  3. bm "go-common/library/net/http/blademaster"
  4. )
  5. func serverInfos(c *bm.Context) {
  6. c.JSON(srv.ServerInfos(c))
  7. }
  8. func serverList(c *bm.Context) {
  9. v := new(struct {
  10. Platform string `form:"platform" validate:"required"`
  11. })
  12. if err := c.Bind(v); err != nil {
  13. return
  14. }
  15. c.JSON(srv.ServerList(c, v.Platform), nil)
  16. }
  17. func serverWeight(c *bm.Context) {
  18. v := new(struct {
  19. IP string `form:"ip"`
  20. })
  21. if err := c.Bind(v); err != nil {
  22. return
  23. }
  24. nodes, region, province, err := srv.ServerWeight(c, v.IP)
  25. if err != nil {
  26. c.JSON(nil, err)
  27. return
  28. }
  29. data := make(map[string]interface{})
  30. data["nodes"] = nodes
  31. data["region"] = region
  32. data["province"] = province
  33. c.JSON(data, err)
  34. }