← ClaudeAtlas

nethttp-architectlisted

Framework-specific delta on rest-api-architect — Go stdlib net/http (Go 1.22+ ServeMux, no router) on Go 1.26. Feature layout, struct-tag validation, RFC 7807 errors, JWT or IdP auth, graceful shutdown, OpenAPI via kin-openapi. Read rest-api-architect first for the cross-cutting REST conventions. Use when scaffolding or reviewing a stdlib net/http service.
ralvarezdev/ralvaskills · ★ 2 · API & Backend · score 75
Install: claude install-skill ralvarezdev/ralvaskills
# net/http Architecture Targets the stdlib **`net/http`** on **Go 1.26**, using the Go 1.22+ enhanced `ServeMux` (method matching, path variables, host matching) — no router framework. Companion to [go-architect](../../languages/go-architect/SKILL.md), [rest-api-architect](../../protocols/rest-api-architect/SKILL.md), and [sql-architect](../../databases/sql-architect/SKILL.md). Implementation skeletons in [RECIPES.md](RECIPES.md); pinned deps in [STACK.md](STACK.md). ## 1. Project structure — feature-based Same shape as `gin-architect` and `fastapi-architect`: one folder per bounded context under `internal/`, each with `handlers.go`, `service.go`, `repo.go`, `dto.go`, `queries/`. Full tree in [RECIPES.md](RECIPES.md). - **`handlers.go`** depends on `service.go`; never reaches into `repo.go` directly. - **`service.go`** is pure Go — no `net/http` imports. Easy to unit-test. - **`dto.go`** holds wire types; never reuse domain structs as DTOs. ## 2. Routing — `http.ServeMux` with method patterns (Go 1.22+) The stdlib `ServeMux` supports method matching, path wildcards (`{id}`), and host matching. No third-party router needed. Registration skeleton in [RECIPES.md](RECIPES.md). - **Method patterns:** `"GET /v1/users/{id}"` — method + path in one string. Mismatched methods auto-return `405 Method Not Allowed`. - **Path variables:** `id := r.PathValue("user_id")` — typed parsing happens in your handler. - **Trailing slash:** `"GET /v1/users/"` matches everything under the pre