web_route.go 1.3 KB

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