Go HTTP Middleware Patterns

•
64
•

Implements idiomatic Go HTTP middleware patterns for context propagation, structured logging, and centralized error handling.

The Go HTTP Middleware skill provides a standardized framework for building robust, observable, and resilient web services in Go. It enforces best practices for the standard library's http.Handler pattern, including type-safe context propagation to avoid key collisions, structured logging using the slog package, and centralized error management. By guiding developers through correct middleware ordering—placing recovery and request tracking at the outermost layers—it ensures that Go applications maintain high availability and provide clear audit trails for every request.

主な機能

0164 GitHub stars
02Standard http.Handler middleware composition patterns
03Structured logging integration using Go 1.21+ slog
04Centralized error handling with custom AppHandler types
05Type-safe context propagation for request-scoped metadata
06Global panic recovery to ensure server stability

ユースケース

01Adding resilient error handling and panic recovery to Go backends
02Building production-ready Go REST APIs with consistent observability
03Implementing authentication and authorization layers across web services