web_route.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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/service/version/switch",
  42. serviceVersionSwitchHandler,
  43. },
  44. {
  45. "/api/network/interfaces",
  46. netInterfaces,
  47. },
  48. {
  49. "/api/network/routes",
  50. netRoutes,
  51. },
  52. {
  53. "/api/network/dns",
  54. netDNS,
  55. },
  56. {
  57. "/api/network/loglevel",
  58. serviceLogLevelHandler(7000),
  59. },
  60. {
  61. "/api/network/logfile",
  62. downloadNetworkLog,
  63. },
  64. {
  65. "/api/network/restart",
  66. restartNetworkService,
  67. },
  68. {
  69. "/api/network/status",
  70. networkStatusHandler,
  71. },
  72. {
  73. "/api/time/loglevel",
  74. serviceLogLevelHandler(7001),
  75. },
  76. {
  77. "/api/time/logfile",
  78. downloadTimeLog,
  79. },
  80. {
  81. "/api/time/restart",
  82. restartTimeService,
  83. },
  84. {
  85. "/api/time/status",
  86. timeStatusHandler,
  87. },
  88. {
  89. "/api/gnss/loglevel",
  90. serviceLogLevelHandler(7002),
  91. },
  92. {
  93. "/api/gnss/logfile",
  94. downloadGnssLog,
  95. },
  96. {
  97. "/api/gnss/restart",
  98. restartGnssService,
  99. },
  100. {
  101. "/api/gnss/status",
  102. gnssStatusHandler,
  103. },
  104. {
  105. "/api/ssh/ws",
  106. sshWSHandler,
  107. },
  108. }
  109. func registerRoutes(mux *http.ServeMux) {
  110. for _, r := range routes {
  111. mux.HandleFunc(r.Path, r.Handler)
  112. }
  113. }