Start initializes and starts the API server. It refuses to start without a token, since an open download proxy is a security risk.
(ctx context.Context)
| 151 | // Start initializes and starts the API server. It refuses to start without a |
| 152 | // token, since an open download proxy is a security risk. |
| 153 | func Start(ctx context.Context) error { |
| 154 | cfg := config.C().API |
| 155 | |
| 156 | if !cfg.Enable { |
| 157 | return nil |
| 158 | } |
| 159 | |
| 160 | if cfg.Token == "" { |
| 161 | return fmt.Errorf("API server is enabled but no token is set; refusing to start insecurely") |
| 162 | } |
| 163 | |
| 164 | server := NewServer(ctx) |
| 165 | if err := server.Start(ctx); err != nil { |
| 166 | return err |
| 167 | } |
| 168 | StartCleanupLoop(ctx) |
| 169 | return nil |
| 170 | } |
no test coverage detected