What problem does it solve?
This Skill provides robust, idiomatic Go HTTP middleware patterns to handle cross-cutting concerns like context propagation, structured logging, error handling, and panic recovery, ensuring cleaner and more resilient Go web services.
Core Features & Use Cases
- Context Propagation: Manages request-scoped data (request IDs, user info) using type-safe context keys.
- Structured Logging: Integrates
slog for consistent, searchable logs with customizable levels and sources.
- Centralized Error Handling: Implements an
AppHandler pattern for consistent error responses and uses a Recovery middleware to prevent panics from crashing the server.
- Use Case: When building a new Go API, use this Skill's middleware to automatically add request IDs, log all incoming requests with relevant details, handle errors gracefully, and ensure the server remains stable even if a handler panics.
Quick Start
Apply the Recovery, RequestID, and Logger middleware to your HTTP router in the correct order.