go-middleware
Idiomatic Go HTTP middleware patterns with context propagation, structured logging via slog, centralized error handling, and panic recovery. Use when writing middleware, adding request tracing, or implementing cross-cutting concerns.
Install via CLI (Recommended)
clawhub install openclaw/skills/skills/anderskev/go-middlewareWhat This Skill Does
The go-middleware skill provides a comprehensive toolkit for implementing robust, idiomatic HTTP middleware in the Go programming language. It is designed to standardize cross-cutting concerns such as request tracing, structured logging, context propagation, and error handling. By utilizing the standard library's net/http patterns and slog for modern structured logging, this skill ensures that your Go services are maintainable, observable, and resilient against panics. It focuses on the decorator pattern, providing clear structures for type-safe context key management and request lifecycle management.
Installation
To integrate this skill into your project via the OpenClaw environment, execute the following command in your terminal:
clawhub install openclaw/skills/skills/anderskev/go-middleware
Use Cases
This skill is best utilized in the following scenarios:
- Service Observability: Implementing request ID generation and structured logging to correlate logs across microservices.
- Authentication/Authorization: Building middleware that intercepts incoming requests, validates tokens, and injects authenticated user data into the request context for downstream handlers to consume.
- Panic Recovery: Implementing a safety net middleware that catches panics during request execution, logs the stack trace, and returns a clean 500 error to the client instead of crashing the server process.
- Standardized Error Handling: Implementing a centralized handler that translates domain-specific errors into standardized JSON HTTP responses.
Example Prompts
- "OpenClaw, use the go-middleware skill to generate a structured logging middleware that captures the HTTP status code, request duration, and method using slog."
- "Help me implement a type-safe context middleware for the go-middleware skill that stores and retrieves a tenant_id from the incoming request headers."
- "Write a panic recovery middleware using the go-middleware patterns that logs the error and returns a formatted JSON error response to the user."
Tips & Limitations
When working with this skill, always prioritize type-safe context keys to avoid collisions, especially in larger projects. Ensure that your middleware handlers are strictly composable and always invoke next.ServeHTTP. Be mindful of the performance overhead introduced by heavy logging inside high-throughput endpoints. This skill is intended for Go 1.21+ environments as it leverages the modern slog package. Note that this skill does not provide an entire routing framework; it is meant to be used alongside standard or third-party routers like chi or gorilla/mux.
Metadata
Not sure this is the right skill?
Describe what you want to build — we'll match you to the best skill from 16,000+ options.
Find the right skillPaste this into your clawhub.json to enable this plugin.
{
"plugins": {
"official-anderskev-go-middleware": {
"enabled": true,
"auto_update": true
}
}
}Tags(AI)
Flags: code-execution
Related Skills
tutorial-docs
Tutorial patterns for documentation - learning-oriented guides that teach through guided doing
fetch-pr-feedback
Fetch review comments from a PR and evaluate with receive-feedback skill
swift-testing-code-review
Reviews Swift Testing code for proper use of
rust-testing-code-review
Reviews Rust test code for unit test patterns, integration test structure, async testing, mocking approaches, and property-based testing. Covers Rust 2024 edition changes including async fn in traits for mocks,
explanation-docs
Explanation documentation patterns for understanding-oriented content - conceptual guides that explain why things work the way they do