| Context keys, request IDs, user metadata | references/context-propagation.md | | slog setup, logging middleware, child loggers | references/structured-logging.md | | AppHandler pattern, domain errors, recovery | references/error-handling-middleware.md |
All middleware follows the standard func(http.Handler) http.Handler pattern. This is the composable building block for cross-cutting concerns in Go HTTP servers.
Use context.WithValue for request-scoped data that crosses API boundaries (request IDs, authenticated users, tenant IDs). Always use typed keys to avoid collisions.
Pattern middleware HTTP Idiomatic Go con propagazione del contesto, registrazione strutturata tramite slog, gestione centralizzata degli errori e ripristino in caso di panico. Da utilizzare durante la scrittura di middleware, l'aggiunta della traccia delle richieste o l'implementazione di problemi trasversali. Fonte: existential-birds/beagle.