@title casaOS API @version 1.0.0 @contact.name lauren.pan @contact.url https://www.zimaboard.com @contact.email lauren.pan@icewhale.org @description casaOS v1版本api @host 192.168.2.217:8089 @securityDefinitions.apikey ApiKeyAuth @in header @name Authorization @BasePath /v1
()
| 101 | // @name Authorization |
| 102 | // @BasePath /v1 |
| 103 | func main() { |
| 104 | if *versionFlag { |
| 105 | return |
| 106 | } |
| 107 | v1Router := route.InitV1Router() |
| 108 | |
| 109 | v2Router := route.InitV2Router() |
| 110 | v2DocRouter := route.InitV2DocRouter(_docHTML, _docYAML) |
| 111 | v3File := route.InitFile() |
| 112 | mux := &util_http.HandlerMultiplexer{ |
| 113 | HandlerMap: map[string]http.Handler{ |
| 114 | "v1": v1Router, |
| 115 | "v2": v2Router, |
| 116 | "v3": v3File, |
| 117 | "doc": v2DocRouter, |
| 118 | }, |
| 119 | } |
| 120 | |
| 121 | crontab := cron.New(cron.WithSeconds()) |
| 122 | if _, err := crontab.AddFunc("@every 5s", route.SendAllHardwareStatusBySocket); err != nil { |
| 123 | logger.Error("add crontab error", zap.Error(err)) |
| 124 | } |
| 125 | |
| 126 | crontab.Start() |
| 127 | defer crontab.Stop() |
| 128 | |
| 129 | listener, err := net.Listen("tcp", net.JoinHostPort(LOCALHOST, "0")) |
| 130 | if err != nil { |
| 131 | panic(err) |
| 132 | } |
| 133 | routers := []string{ |
| 134 | "/v1/sys", |
| 135 | "/v1/port", |
| 136 | "/v1/file", |
| 137 | "/v1/folder", |
| 138 | "/v1/batch", |
| 139 | "/v1/image", |
| 140 | "/v1/samba", |
| 141 | "/v1/notify", |
| 142 | "/v1/driver", |
| 143 | "/v1/cloud", |
| 144 | "/v1/recover", |
| 145 | "/v1/other", |
| 146 | "/v1/zt", |
| 147 | "/v1/test", |
| 148 | route.V2APIPath, |
| 149 | route.V2DocPath, |
| 150 | route.V3FilePath, |
| 151 | } |
| 152 | for _, apiPath := range routers { |
| 153 | err = service.MyService.Gateway().CreateRoute(&model.Route{ |
| 154 | Path: apiPath, |
| 155 | Target: "http://" + listener.Addr().String(), |
| 156 | }) |
| 157 | if err != nil { |
| 158 | fmt.Println("err", err) |
| 159 | panic(err) |
| 160 | } |
nothing calls this directly
no test coverage detected