mirror of
https://github.com/hanzoai/o11y-mcp.git
synced 2026-10-30 18:26:37 +00:00
## Before it needs `SIGNOZ_API_KEY` as env variable when running the mcp server ## After it could pass `SIGNOZ_API_KEY` over the `Authorization` header so that it could manage access to this mcp server at application level. --------- Co-authored-by: Hanzo Dev <[email protected]>
19 lines
457 B
Go
19 lines
457 B
Go
package util
|
|
|
|
import "context"
|
|
|
|
type contextKey string
|
|
|
|
const apiKeyContextKey contextKey = "api_key"
|
|
|
|
// SetAPIKey stores the API key in the context
|
|
func SetAPIKey(ctx context.Context, apiKey string) context.Context {
|
|
return context.WithValue(ctx, apiKeyContextKey, apiKey)
|
|
}
|
|
|
|
// GetAPIKey retrieves the API key from the context
|
|
func GetAPIKey(ctx context.Context) (string, bool) {
|
|
apiKey, ok := ctx.Value(apiKeyContextKey).(string)
|
|
return apiKey, ok
|
|
}
|