web_route.go 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. package main
  2. import (
  3. "net/http"
  4. )
  5. type Route struct {
  6. Path string
  7. Handler http.HandlerFunc
  8. }
  9. var routes = []Route{
  10. {
  11. "/api/auth/login",
  12. loginHandler,
  13. },
  14. {
  15. "/api/auth/logout",
  16. logoutHandler,
  17. },
  18. {
  19. "/api/device/imei",
  20. getIMEIHandler,
  21. },
  22. {
  23. "/api/system/reboot",
  24. systemRebootHandler,
  25. },
  26. {
  27. "/api/service/log",
  28. serviceLogHandler,
  29. },
  30. {
  31. "/api/system/info",
  32. systemInfoHandler,
  33. },
  34. {
  35. "/api/system/loadAverage",
  36. systemLoadAverageHandler,
  37. },
  38. {
  39. "/api/system/serviceStatus",
  40. serviceStatusHandler,
  41. },
  42. {
  43. "/api/service/version/switch",
  44. serviceVersionSwitchHandler,
  45. },
  46. {
  47. "/api/network/interfaces",
  48. netInterfaces,
  49. },
  50. {
  51. "/api/network/routes",
  52. netRoutes,
  53. },
  54. {
  55. "/api/network/dns",
  56. netDNS,
  57. },
  58. {
  59. "/api/network/loglevel",
  60. serviceLogLevelHandler(7000),
  61. },
  62. {
  63. "/api/network/logfile",
  64. downloadNetworkLog,
  65. },
  66. {
  67. "/api/network/restart",
  68. restartNetworkService,
  69. },
  70. {
  71. "/api/network/status",
  72. networkStatusHandler,
  73. },
  74. {
  75. "/api/time/loglevel",
  76. serviceLogLevelHandler(7001),
  77. },
  78. {
  79. "/api/time/logfile",
  80. downloadTimeLog,
  81. },
  82. {
  83. "/api/time/restart",
  84. restartTimeService,
  85. },
  86. {
  87. "/api/time/status",
  88. timeStatusHandler,
  89. },
  90. {
  91. "/api/gnss/loglevel",
  92. serviceLogLevelHandler(7002),
  93. },
  94. {
  95. "/api/gnss/logfile",
  96. downloadGnssLog,
  97. },
  98. {
  99. "/api/gnss/restart",
  100. restartGnssService,
  101. },
  102. {
  103. "/api/gnss/status",
  104. gnssStatusHandler,
  105. },
  106. {
  107. "/api/camera/loglevel",
  108. serviceLogLevelHandler(7003),
  109. },
  110. {
  111. "/api/camera/logfile",
  112. downloadCameraLog,
  113. },
  114. {
  115. "/api/camera/restart",
  116. restartCameraService,
  117. },
  118. {
  119. "/api/camera/status",
  120. cameraStatusHandler,
  121. },
  122. {
  123. "/api/camera/gpio22power",
  124. cameraPowerHandler,
  125. },
  126. {
  127. "/api/camera/pingGigeCamera",
  128. cameraPingHandler,
  129. },
  130. {
  131. "/api/camera/takePhoto",
  132. cameraTakePhotoHandler,
  133. },
  134. {
  135. "/api/camera/getImage",
  136. cameraGetImageHandler,
  137. },
  138. {
  139. "/api/camera/setWaitAEDoneForTakePhoto",
  140. setWaitAEDoneForTakePhoto,
  141. },
  142. {
  143. "/api/app-install/loglevel",
  144. serviceLogLevelHandler(7004),
  145. },
  146. {
  147. "/api/app-install/logfile",
  148. downloadAppInstallLog,
  149. },
  150. {
  151. "/api/app-install/restart",
  152. restartAppInstallService,
  153. },
  154. {
  155. "/api/app-install/status",
  156. appInstallStatusHandler,
  157. },
  158. {
  159. "/api/app-install/uploadUserAppPkg",
  160. uploadUserAppPkg,
  161. },
  162. {
  163. "/api/app-install/importUserAppPkg",
  164. appPkgImportHandler,
  165. },
  166. {
  167. "/api/app-install/downloadUserAppPkg",
  168. downloadUserAppPkg,
  169. },
  170. {
  171. "/api/app-install/removeUserAppPkg",
  172. appPkgRemoveHandler,
  173. },
  174. {
  175. "/api/app-install/installUserApp",
  176. appInstallHandler,
  177. },
  178. {
  179. "/api/app-install/uninstallUserApp",
  180. appUninstallHandler,
  181. },
  182. {
  183. "/api/user-app/restart",
  184. restartUserAppService,
  185. },
  186. {
  187. "/api/ssh/ws",
  188. sshWSHandler,
  189. },
  190. }
  191. func registerRoutes(mux *http.ServeMux) {
  192. for _, r := range routes {
  193. mux.HandleFunc(r.Path, r.Handler)
  194. }
  195. }