web_route.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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/system/reboot",
  22. systemRebootHandler,
  23. },
  24. {
  25. "/api/service/log",
  26. serviceLogHandler,
  27. },
  28. {
  29. "/api/system/info",
  30. systemInfoHandler,
  31. },
  32. {
  33. "/api/system/loadAverage",
  34. systemLoadAverageHandler,
  35. },
  36. {
  37. "/api/system/serviceStatus",
  38. serviceStatusHandler,
  39. },
  40. {
  41. "/api/network/interfaces",
  42. netInterfaces,
  43. },
  44. {
  45. "/api/network/routes",
  46. netRoutes,
  47. },
  48. {
  49. "/api/network/dns",
  50. netDNS,
  51. },
  52. {
  53. "/api/network/loglevel",
  54. serviceLogLevelHandler(7000),
  55. },
  56. {
  57. "/api/network/logfile",
  58. downloadNetworkLog,
  59. },
  60. {
  61. "/api/network/restart",
  62. restartNetworkService,
  63. },
  64. {
  65. "/api/network/status",
  66. networkStatusHandler,
  67. },
  68. {
  69. "/api/time/loglevel",
  70. serviceLogLevelHandler(7001),
  71. },
  72. {
  73. "/api/time/logfile",
  74. downloadTimeLog,
  75. },
  76. {
  77. "/api/time/restart",
  78. restartTimeService,
  79. },
  80. {
  81. "/api/time/status",
  82. timeStatusHandler,
  83. },
  84. {
  85. "/api/gnss/loglevel",
  86. serviceLogLevelHandler(7002),
  87. },
  88. {
  89. "/api/gnss/logfile",
  90. downloadGnssLog,
  91. },
  92. {
  93. "/api/gnss/restart",
  94. restartGnssService,
  95. },
  96. {
  97. "/api/gnss/status",
  98. gnssStatusHandler,
  99. },
  100. {
  101. "/api/ssh/ws",
  102. sshWSHandler,
  103. },
  104. }
  105. func registerRoutes(mux *http.ServeMux) {
  106. for _, r := range routes {
  107. mux.HandleFunc(r.Path, r.Handler)
  108. }
  109. }