http-patterns

Implement Go 1.22+ ServeMux routing, middleware stacks, and graceful shutdown.

2|Updated Feb 6, 2026
One-click install
npx skills add https://github.com/air-gapped/cooked --skill http-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: http-patterns
Source: https://github.com/air-gapped/cooked/tree/main/.claude/skills/http-patterns
Command: npx skills add https://github.com/air-gapped/cooked --skill http-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Go HTTP routing and lifecycle management can be verbose and error-prone. This skill provides a concise set of patterns for method routing, middleware composition, and graceful shutdown to standardize server code across Go services.

Core Features & Use Cases

  • ServeMux Method Routing: Register handlers using method-prefixed routes and clear precedence rules to reduce boilerplate and errors.
  • Middleware Composition: Build reusable middleware stacks for logging, authentication, metrics, and context propagation without tight coupling.
  • Graceful Shutdown Patterns: Implement ready/shutdown semantics and context-aware shutdown to support Kubernetes and scalable deployments.
  • Go 1.22+ Patterns: Leverage new Go routing enhancements for clear, predictable request handling and path parameters.

Quick Start

Start with a minimal Go 1.22+ server, register routes with the ServeMux-based patterns, add a health endpoint, and observe automatic 405 handling and graceful shutdown behavior.

Frequently Asked Questions about http-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I handle method-specific HTTP routing in Go 1.22 without third-party frameworks?

Method-specific HTTP routing in Go 1.22 is handled using pattern-based ServeMux. This allows registering handlers with method-prefixed routes to enforce precise request handling and automatic 405 responses without external dependencies.

What is the best way to compose middleware stacks for Go microservices?

Composing middleware for Go microservices involves building reusable layers for logging, authentication, and metrics. This pattern decouples middleware from core logic, enabling clean context propagation across the request lifecycle.

How does graceful shutdown work for Go services deployed on Kubernetes?

Graceful shutdown for Go services on Kubernetes uses context-aware lifecycle handling and ready/shutdown semantics. This pattern ensures connections drain properly during pod termination, supporting scalable deployments without dropping active requests.

Does Go 1.22 ServeMux support path parameters for microservice routing?

Yes, Go 1.22 ServeMux supports path parameters through enhanced routing patterns. This feature provides clear, predictable request handling and allows precise path variable extraction for microservice endpoints.

Why does my Go HTTP server return automatic 405 responses for unmatched methods?

Automatic 405 responses occur when using method-prefixed routes in Go 1.22 ServeMux. If a request path matches but the HTTP method does not, the router enforces this pattern and automatically rejects the request with a 405 status.

Can I use standard library routing for complex microservice middleware orchestration?

Standard library routing handles complex microservice middleware orchestration by leveraging Go 1.22 ServeMux patterns. It enables method-specific routing, context management utilities, and middleware layering to standardize server code across services.