go-handlers

Creates Go HTTP handlers with thin-controller architecture and Chi routing.

1|Updated Mar 30, 2026
One-click install
npx skills add https://github.com/anicdh/agstack --skill go-handlers
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: go-handlers
Source: https://github.com/anicdh/agstack/tree/main/.claude/skills/go/go-handlers
Command: npx skills add https://github.com/anicdh/agstack --skill go-handlers

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Long, fat HTTP handlers in Go make testing and maintenance painful. This skill guides you to keep handlers thin and push business logic into services.

Core Features & Use Cases

  • Thin handlers: keep request handling lightweight and delegate business logic to services.
  • Input validation & error handling: validate inputs and return structured error responses.
  • Route registration & middleware patterns: centralize route wiring and demonstrate common middleware (logging, auth).

Use case: build REST endpoints for resources with predictable shapes and testability.

Quick Start

Implement a new Go HTTP handler following the thin-handler pattern and wire it into your router.

Frequently Asked Questions about go-handlers

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

FAQPage Schema
How do I keep Go HTTP handlers thin and move business logic to a service layer?

To keep Go HTTP handlers thin, you delegate request parsing and response writing to the handler while pushing business logic into a dedicated service layer. This pattern ensures controllers remain lightweight, testable, and focused on HTTP concerns.

What is the best way to structure input validation and error handling in Go REST endpoints?

Structuring input validation in Go REST endpoints requires validating requests early and returning structured JSON responses using a standard error model like AppError. This approach centralizes error handling and ensures predictable API behavior across all routes.

How do I centralize route registration and configure middleware using the Chi router in Go?

Centralizing route registration with the Chi router involves grouping endpoints and applying common middleware such as logging and authentication in one place. This wiring pattern streamlines route management and enforces consistent request processing.

Does this Go handler pattern work for building testable RESTful APIs without fat controllers?

Yes, this Go handler pattern is designed specifically for building testable RESTful APIs by enforcing thin handlers and a service layer. By separating business logic from controllers, you gain reliable unit testing and predictable endpoint behavior.

Why should I use a standard error model and adapter helpers for Go HTTP responses?

Using a standard error model and adapter helpers for Go HTTP responses ensures consistent JSON output and centralized error mapping. This setup prevents scattered response logic and makes maintaining reliable API error structures significantly easier.