web_route.go 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  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/service/log/close",
  32. serviceLogCloseHandler,
  33. },
  34. {
  35. "/api/service/control",
  36. serviceControlHandler,
  37. },
  38. {
  39. "/api/files/unlock",
  40. fmUnlockHandler,
  41. },
  42. {
  43. "/api/files/list",
  44. fmListHandler,
  45. },
  46. {
  47. "/api/files/download",
  48. fmDownloadHandler,
  49. },
  50. {
  51. "/api/files/upload",
  52. fmUploadHandler,
  53. },
  54. {
  55. "/api/system/info",
  56. systemInfoHandler,
  57. },
  58. {
  59. "/api/system/loadAverage",
  60. systemLoadAverageHandler,
  61. },
  62. {
  63. "/api/system/serviceStatus",
  64. serviceStatusHandler,
  65. },
  66. {
  67. "/api/service/version/switch",
  68. serviceVersionSwitchHandler,
  69. },
  70. {
  71. "/api/upgrade/logfile",
  72. downloadUpgradeLog,
  73. },
  74. {
  75. "/api/upgrade/getUpgradeConfig",
  76. getUpgradeConfig,
  77. },
  78. {
  79. "/api/network/interfaces",
  80. netInterfaces,
  81. },
  82. {
  83. "/api/network/routes",
  84. netRoutes,
  85. },
  86. {
  87. "/api/network/dns",
  88. netDNS,
  89. },
  90. {
  91. "/api/network/loglevel",
  92. serviceLogLevelHandler(7000),
  93. },
  94. {
  95. "/api/network/logfile",
  96. downloadNetworkLog,
  97. },
  98. {
  99. "/api/network/restart",
  100. restartNetworkService,
  101. },
  102. {
  103. "/api/network/status",
  104. networkStatusHandler,
  105. },
  106. {
  107. "/api/time/loglevel",
  108. serviceLogLevelHandler(7001),
  109. },
  110. {
  111. "/api/time/logfile",
  112. downloadTimeLog,
  113. },
  114. {
  115. "/api/time/restart",
  116. restartTimeService,
  117. },
  118. {
  119. "/api/time/status",
  120. timeStatusHandler,
  121. },
  122. {
  123. "/api/gnss/loglevel",
  124. serviceLogLevelHandler(7002),
  125. },
  126. {
  127. "/api/gnss/logfile",
  128. downloadGnssLog,
  129. },
  130. {
  131. "/api/gnss/restart",
  132. restartGnssService,
  133. },
  134. {
  135. "/api/gnss/status",
  136. gnssStatusHandler,
  137. },
  138. {
  139. "/api/camera/loglevel",
  140. serviceLogLevelHandler(7003),
  141. },
  142. {
  143. "/api/camera/logfile",
  144. downloadCameraLog,
  145. },
  146. {
  147. "/api/camera/restart",
  148. restartCameraService,
  149. },
  150. {
  151. "/api/camera/status",
  152. cameraStatusHandler,
  153. },
  154. {
  155. "/api/camera/gpio22power",
  156. cameraPowerHandler,
  157. },
  158. {
  159. "/api/camera/pingGigeCamera",
  160. cameraPingHandler,
  161. },
  162. {
  163. "/api/camera/takePhoto",
  164. cameraTakePhotoHandler,
  165. },
  166. {
  167. "/api/camera/getImage",
  168. cameraGetImageHandler,
  169. },
  170. {
  171. "/api/camera/setWaitAEDoneForTakePhoto",
  172. setWaitAEDoneForTakePhoto,
  173. },
  174. {
  175. "/api/app-install/loglevel",
  176. serviceLogLevelHandler(7004),
  177. },
  178. {
  179. "/api/app-install/logfile",
  180. downloadAppInstallLog,
  181. },
  182. {
  183. "/api/app-install/restart",
  184. restartAppInstallService,
  185. },
  186. {
  187. "/api/app-install/status",
  188. appInstallStatusHandler,
  189. },
  190. {
  191. "/api/app-install/uploadUserAppPkg",
  192. uploadUserAppPkg,
  193. },
  194. {
  195. "/api/app-install/importUserAppPkg",
  196. appPkgImportHandler,
  197. },
  198. {
  199. "/api/app-install/downloadUserAppPkg",
  200. downloadUserAppPkg,
  201. },
  202. {
  203. "/api/app-install/removeUserAppPkg",
  204. appPkgRemoveHandler,
  205. },
  206. {
  207. "/api/app-install/installUserApp",
  208. appInstallHandler,
  209. },
  210. {
  211. "/api/app-install/uninstallUserApp",
  212. appUninstallHandler,
  213. },
  214. {
  215. "/api/user-app/restart",
  216. restartUserAppService,
  217. },
  218. {
  219. "/api/health-check/network",
  220. healthCheckNetworkHandler,
  221. },
  222. {
  223. "/api/health-check/time",
  224. healthCheckTimeHandler,
  225. },
  226. {
  227. "/api/health-check/position",
  228. healthCheckPositionHandler,
  229. },
  230. {
  231. "/api/health-check/camera",
  232. healthCheckCameraHandler,
  233. },
  234. {
  235. "/api/health-check/camera/photo",
  236. healthCheckCameraPhotoHandler,
  237. },
  238. {
  239. "/api/health-check/user-app",
  240. healthCheckUserAppHandler,
  241. },
  242. {
  243. "/api/ssh/ws",
  244. sshWSHandler,
  245. },
  246. {
  247. "/api/cbd/loglevel",
  248. serviceLogLevelHandler(7200),
  249. },
  250. {
  251. "/api/cbd/logfile",
  252. downloadCBDAppLog,
  253. },
  254. {
  255. "/api/cbd/serverCfg",
  256. cbdServerCfgHandler,
  257. },
  258. {
  259. "/api/cbd/getWorkStatus",
  260. cbdRunStatusHandler,
  261. },
  262. {
  263. "/api/cbd/unlock",
  264. cbdUnlockHandler,
  265. },
  266. {
  267. "/api/cbd/writeMCUData",
  268. cbdWriteMCUDataHandler,
  269. },
  270. {
  271. "/api/cbd/uploadFirmware",
  272. cbdUploadFirmwareHandler,
  273. },
  274. }
  275. func registerRoutes(mux *http.ServeMux) {
  276. for _, r := range routes {
  277. mux.HandleFunc(r.Path, r.Handler)
  278. }
  279. }