Documentation
¶
Overview ¶
Package middleware provides production-ready HTTP middleware for serverless Lambda functions and local HTTP servers. All log output is structured JSON so entries are queryable with log aggregators (e.g. CloudWatch Logs Insights) without parsing.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoggingMiddleware ¶
LoggingMiddleware logs structured JSON entries for every request and response. Request entries include method, path, source IP, user agent, and request ID. Response entries add HTTP status, latency (ms), and an extracted error message for 4xx/5xx responses. Log level follows HTTP status: info/warn/error.
Compatible with any net/http handler, including chi routers.
func RecoverMiddleware ¶
RecoverMiddleware catches panics in downstream handlers, logs a structured entry with the full stack trace, and writes a 500 Internal Server Error response. Without this middleware a panic crashes the Lambda invocation and returns an opaque 502 from API Gateway.
func RequestIDFromContext
deprecated
Types ¶
This section is empty.