mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-02 20:40:52 +08:00
Previously, management API routes were conditionally registered at server startup based on the presence of the `remote-management-key`. This static approach meant a server restart was required to enable or disable these endpoints. This commit refactors the route handling by: 1. Introducing an `atomic.Bool` flag, `managementRoutesEnabled`, to track the state. 2. Always registering the management routes at startup. 3. Adding a new `managementAvailabilityMiddleware` to the management route group. This middleware checks the `managementRoutesEnabled` flag for each request, rejecting it if management is disabled. This change provides the same initial behavior but creates a more flexible architecture that will allow for dynamically enabling or disabling management routes at runtime in the future.