web_route.go 854 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. package main
  2. import "net/http"
  3. type Route struct {
  4. Path string
  5. Handler http.HandlerFunc
  6. }
  7. var routes = []Route{
  8. {
  9. "/api/auth/login",
  10. loginHandler,
  11. },
  12. {
  13. "/api/auth/logout",
  14. logoutHandler,
  15. },
  16. {
  17. "/api/device/imei",
  18. getIMEIHandler,
  19. },
  20. {
  21. "/api/sshd/status",
  22. sshdStatusHandler,
  23. },
  24. {
  25. "/api/service/log",
  26. serviceLogHandler,
  27. },
  28. {
  29. "/api/network/interfaces",
  30. netInterfaces,
  31. },
  32. {
  33. "/api/network/routes",
  34. netRoutes,
  35. },
  36. {
  37. "/api/network/dns",
  38. netDNS,
  39. },
  40. {
  41. "/api/network/loglevel",
  42. serviceLogLevelHandler(7000),
  43. },
  44. {
  45. "/api/network/logfile",
  46. downloadNetworkLog,
  47. },
  48. {
  49. "/api/network/restart",
  50. restartNetworkService,
  51. },
  52. {
  53. "/api/network/status",
  54. networkStatusHandler,
  55. },
  56. }
  57. func registerRoutes(mux *http.ServeMux) {
  58. for _, r := range routes {
  59. mux.HandleFunc(r.Path, r.Handler)
  60. }
  61. }