Documentation
¶
Index ¶
- func CtxWithClientIP(ctx context.Context, ip string) context.Context
- func CtxWithJWT(ctx context.Context, jwt auth.AuthToken) context.Context
- func CtxWithLogger(ctx context.Context, logger *slog.Logger) context.Context
- func CtxWithRefreshTokenID(ctx context.Context, tokenID string) context.Context
- func CtxWithSpanID(ctx context.Context, spanID string) context.Context
- func CtxWithTraceID(ctx context.Context, traceID string) context.Context
- func GetClientIPFromCtx(ctx context.Context) (string, bool)
- func GetJWTFromCtx(ctx context.Context) (auth.AuthToken, bool)
- func GetLoggerFromCtx(ctx context.Context) (*slog.Logger, bool)
- func GetRefreshTokenIDFromCtx(ctx context.Context) (string, bool)
- func GetSpanIDFromCtx(ctx context.Context) (string, bool)
- func GetTraceIDFromCtx(ctx context.Context) (string, bool)
- func OTELHandler(next http.Handler) http.Handler
- func UseMiddlewares(r *http.ServeMux, middlewares ...MiddlewareFunc) http.Handler
- type CorsConfig
- type MiddlewareFunc
- func AccessLogging(baseLogger *slog.Logger) MiddlewareFunc
- func BaseNamePrefix(logger *slog.Logger, baseName string) MiddlewareFunc
- func CorsMiddleware(config CorsConfig) MiddlewareFunc
- func FlushTraces(flush func(context.Context) error, logger *slog.Logger, timeout time.Duration) MiddlewareFunc
- func HostSwaggerUI(basePath string, spec *openapi3.T) (MiddlewareFunc, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CtxWithClientIP ¶ added in v0.5.0
func CtxWithRefreshTokenID ¶ added in v0.2.0
CtxWithRefreshTokenID stores a refresh token ID in the context
func CtxWithSpanID ¶ added in v0.3.0
func CtxWithTraceID ¶ added in v0.3.0
func GetClientIPFromCtx ¶ added in v0.5.0
func GetRefreshTokenIDFromCtx ¶ added in v0.2.0
GetRefreshTokenIDFromCtx retrieves a refresh token ID from the context
func OTELHandler ¶ added in v0.4.0
OTELHandler wraps the provided handler with OpenTelemetry HTTP tracing. It uses a span name formatter of "METHOD PATH" (e.g. "GET /login/v1/sessions").
func UseMiddlewares ¶
func UseMiddlewares(r *http.ServeMux, middlewares ...MiddlewareFunc) http.Handler
Types ¶
type CorsConfig ¶ added in v0.2.0
CorsConfig holds configuration for CORS middleware
func DefaultCorsConfig ¶ added in v0.2.0
func DefaultCorsConfig() CorsConfig
DefaultCorsConfig returns a default CORS configuration for ICAA services
type MiddlewareFunc ¶
func AccessLogging ¶
func AccessLogging(baseLogger *slog.Logger) MiddlewareFunc
func BaseNamePrefix ¶
func BaseNamePrefix(logger *slog.Logger, baseName string) MiddlewareFunc
func CorsMiddleware ¶ added in v0.2.0
func CorsMiddleware(config CorsConfig) MiddlewareFunc
CorsMiddleware creates a CORS middleware with the given configuration
func FlushTraces ¶ added in v0.4.0
func FlushTraces(flush func(context.Context) error, logger *slog.Logger, timeout time.Duration) MiddlewareFunc
FlushTraces returns a middleware that flushes trace spans after the request has been handled. The flush runs with the provided timeout. If flush is nil, the middleware is a no-op.
func HostSwaggerUI ¶
func HostSwaggerUI(basePath string, spec *openapi3.T) (MiddlewareFunc, error)