diff --git a/internal/server/api/listener.go b/internal/server/api/listener.go index d4a03d1d..0eca1ab6 100644 --- a/internal/server/api/listener.go +++ b/internal/server/api/listener.go @@ -40,7 +40,7 @@ type BaseConfig struct { } // GetConfigFromContext returns the config from the context. -// experimental since it is not used yet and may pose cylical dependency issues +// experimental since it is not used yet and may pose cyclical dependency issues // in handlers that are called by the generated // swagger code. This needs to be verified. //func GetConfigFromContext(ctx echo.Context) (Config, error) { @@ -198,9 +198,13 @@ func New(ctx context.Context, cfg Config) (*Server, error) { // Add config middleware before other middleware // so that the config is available to all middleware and handlers. + // If there are issues accessing this from a controller then just set the individual + // config values by name here as needed. You can also use the reflection method used in + // internal/serviceconfig/common.go printConfigRecursive() to copy all of the config values to + // the context by name. This would be guaranteed to be cycle free. e.Use(func(next echo.HandlerFunc) echo.HandlerFunc { return func(c echo.Context) error { - c.Set(string(configContextKey), cfg) + c.Set(configContextKey, cfg) return next(c) } })