ClawKit Logo
ClawKitReliability Toolkit
Back to Registry
Official Verified developer tools Safety 5/5

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.

skill-install — Terminal

Install via CLI (Recommended)

clawhub install openclaw/skills/skills/anderskev/go-middleware
Or

What 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:

  1. Service Observability: Implementing request ID generation and structured logging to correlate logs across microservices.
  2. Authentication/Authorization: Building middleware that intercepts incoming requests, validates tokens, and injects authenticated user data into the request context for downstream handlers to consume.
  3. 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.
  4. Standardized Error Handling: Implementing a centralized handler that translates domain-specific errors into standardized JSON HTTP responses.

Example Prompts

  1. "OpenClaw, use the go-middleware skill to generate a structured logging middleware that captures the HTTP status code, request duration, and method using slog."
  2. "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."
  3. "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

Author@anderskev
Stars4473
Views1
Updated2026-05-01
View Author Profile
AI Skill Finder

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 skill
Add to Configuration

Paste this into your clawhub.json to enable this plugin.

{
  "plugins": {
    "official-anderskev-go-middleware": {
      "enabled": true,
      "auto_update": true
    }
  }
}

Tags(AI)

#go#http#middleware#backend#observability
Safety Score: 5/5

Flags: code-execution