middleware

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UserContextKey = "user_id"
)

Variables

This section is empty.

Functions

func AuthMiddleware

func AuthMiddleware(jwtManager *utils.JWTManager) echo.MiddlewareFunc

func RateLimiter added in v0.2.0

func RateLimiter(perMinute int, burst int) echo.MiddlewareFunc

func ZerologAccessLogger added in v0.4.1

func ZerologAccessLogger() echo.MiddlewareFunc

ZerologAccessLogger returns an Echo RequestLoggerWithConfig that emits one structured JSON access-log line per completed request using zerolog. It replaces middleware.RequestLogger() which emits plain text.

Fields logged: request_id, method, uri, status, remote_ip, latency_ms. Query strings are preserved for diagnostic value (e.g. ?since=...&limit=100) but values for parameters listed in sensitiveQueryParams (e.g. "token") are replaced with "[REDACTED]" before logging. Access logs are emitted at Info level, so they do not reach PostHog (which filters to warn-and-above).

func ZerologRequestLogger added in v0.4.1

func ZerologRequestLogger() echo.MiddlewareFunc

ZerologRequestLogger returns an Echo middleware that derives a per-request zerolog.Logger carrying the request_id injected by middleware.RequestID(), and stores it on the request context. Downstream handlers retrieve it via:

zerolog.Ctx(c.Request().Context()).Info()...

Every log line emitted that way will automatically include the request_id field, making it trivial to correlate all log output for a single request.

This middleware must be registered AFTER middleware.RequestID() in the stack.

Types

This section is empty.

Jump to

Keyboard shortcuts

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