Skip to content
Snippets Groups Projects
Commit 18280814 authored by Christophe de Vienne's avatar Christophe de Vienne
Browse files

Add a hook for api configuration by outer packages

parent 1be3817b
No related branches found
No related tags found
No related merge requests found
...@@ -30,6 +30,14 @@ ...@@ -30,6 +30,14 @@
extraMiddleware = append(extraMiddleware, f) extraMiddleware = append(extraMiddleware, f)
} }
type APIConfigurator func(config APIConfig, auth *auth.Auth, api *operations.RednerdAPI) error
var configurators []APIConfigurator
func AddAPIConfigurator(cfg APIConfigurator) {
configurators = append(configurators, cfg)
}
// APIConfig holds the configuration options for the API. // APIConfig holds the configuration options for the API.
type APIConfig struct { type APIConfig struct {
Context context.Context Context context.Context
...@@ -121,6 +129,12 @@ ...@@ -121,6 +129,12 @@
auth.Close() auth.Close()
} }
for _, cfg := range configurators {
if err := cfg(config, auth, api); err != nil {
panic(err)
}
}
handler := api.Serve(setupMiddlewares) handler := api.Serve(setupMiddlewares)
if s.Prometheus { if s.Prometheus {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment