middlewares

package
v0.0.0-...-d09923a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2026 License: LGPL-2.1 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HeaderIdempotencyId = telemetry.HeaderIdempotencyId
)
View Source
const (
	HeaderTraceId = "X-Trace-ID"
)

Variables

This section is empty.

Functions

func AccessLogMiddleware

func AccessLogMiddleware(logger logging.LoggerService) echo.MiddlewareFunc

AccessLogMiddleware writes one line per request: method, route template, status and duration, never the query string or headers. It hands a handler error to the HTTP error handler, as Echo's RequestLogger did, so the status it logs is the one sent. It reads the request context only after the inner middlewares ran, so the line carries the idempotency id they resolved.

func CorsEchoMiddleware

func CorsEchoMiddleware() echo.MiddlewareFunc

An Echo middleware that supports re-configuring CORS at runtime. Only takes effect if enabled in the configuration.

func EnsureAuthorized

func EnsureAuthorized(next echo.HandlerFunc) echo.HandlerFunc

Ensure the request is authorized by any of the processing layers.

func IdempotencyMiddleware

func IdempotencyMiddleware(logger logging.LoggerService, rejectVia ...echo.MiddlewareFunc) echo.MiddlewareFunc

IdempotencyMiddleware takes a valid X-Idempotency-ID over or mints one when the header is absent, and answers it in the response. A header that is present but empty, malformed or repeated is a 400: replacing it would hide a caller that loses its ID between retries.

The 400 is answered through rejectVia (the CORS middleware in the server chain): CORS sits further in, so without it a cross-origin browser could not read the rejection. Only this path runs it, so an accepted request still gets its CORS headers exactly once, from the chain.

func PublicUnauthorized

func PublicUnauthorized(next echo.HandlerFunc) echo.HandlerFunc

func RecoverMiddleware

func RecoverMiddleware(logger logging.LoggerService) echo.MiddlewareFunc

RecoverMiddleware turns a handler panic into an error the HTTP error handler answers as a generic 500, as Echo's Recover did. The panic value may hold request data, so the message that reaches the log and the span is stripped of control characters and truncated. The error is created inside the deferred recover, so its stack trace still shows the panicking frames.

func RequestContextMiddleware

func RequestContextMiddleware(next echo.HandlerFunc) echo.HandlerFunc

RequestContextMiddleware opens the request context and labels it as an HTTP execution. It mints no id: the trace id (X-Trace-ID) is what correlates a request's audit entries and log lines.

func ServiceAuthorizeMiddleware

func ServiceAuthorizeMiddleware() echo.MiddlewareFunc

Placeholder for routes called by other services with a service token in the `Authorization` header. It passes every request through until service tokens are issued; the verification it will rely on is already RequestGuardService.VerifyServiceAccessToken.

func ServiceAuthz

func ServiceAuthz() echo.MiddlewareFunc

Shortcut for lazy-wrapped ServiceAuthorizeMiddleware.

func TracingMiddleware

func TracingMiddleware(next echo.HandlerFunc) echo.HandlerFunc

TracingMiddleware must be the first middleware. It continues a valid inbound traceparent or starts a root SERVER span, and answers X-Trace-ID before anything else can write the response. A handler error is rendered here, inside the span, so the span records the status sent.

func UserSmokeAuthorizeMiddleware

func UserSmokeAuthorizeMiddleware() echo.MiddlewareFunc

Verifies the user access token and loads the user's permissions into the request context.

func UserSmokeAuthz

func UserSmokeAuthz() echo.MiddlewareFunc

Shortcut for lazy-wrapped UserSmokeAuthorizeMiddleware.

Types

type LazyMiddleware

type LazyMiddleware struct {
	// contains filtered or unexported fields
}

func Lazyware

func Lazyware(middlewareCreator func() echo.MiddlewareFunc) *LazyMiddleware

func (*LazyMiddleware) Enable

func (this *LazyMiddleware) Enable()

func (*LazyMiddleware) Middleware

func (this *LazyMiddleware) Middleware() echo.MiddlewareFunc

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL