sandgardenhq/sgai/go-http-server-routes
Claude Code and agent skill by sandgardenhq/sgai
- community
Checking that the SKILL.md file is still in the repository.
Go 1.22+ enhanced HTTP routing with method matching and wildcards. When defining HTTP routes using net/http ServeMux in Go 1.22+
Install
npx vskill@latest install sandgardenhq/sgai/go-http-server-routesSKILL.md
Go HTTP Server Routes (Go 1.22+)
Enhanced routing patterns for net/http.ServeMux introduced in Go 1.22.
Reference URLs
- https://go.dev/blog/routing-enhancements - Official announcement
- https://pkg.go.dev/net/http#ServeMux - ServeMux documentation
Method Matching
Specify HTTP methods directly in patterns:
GETalso matchesHEADrequests- All other methods match exactly
- Unmatched methods return
405 Method Not AllowedwithAllowheader
Wildcards
Single Segment: {name}
Matches exactly one path segment:
Remaining Segments: {name...}
Matches all remaining path segments:
Exact Trailing Slash: {$}
Matches only the path with trailing slash:
| Pattern | Matches | Does Not Match | |
|---|---|---|---|
/posts/{$} | /posts/ | /posts, /posts/123 | |
/posts/ | /posts/, /posts/123, /posts/a/b | /posts | |
/posts/{id} | /posts/123 | /posts/, /posts/a/b |
PathValue API
Extract wildcard values from requests:
For third-party routers to integrate:
Precedence Rules
The most specific pattern wins. A pattern is more specific if it matches a strict subset of requests.
Examples
| Pattern A | Pattern B | Winner | Reason | |
|---|---|---|---|---|
/posts/latest | /posts/{id} | A | Literal matches fewer requests | |
GET /posts/{id} | /posts/{id} | A | Method constraint is more specific | |
/users/{u}/posts/latest | /users/{u}/posts/{id} | A | Literal segment more specific |
Conflicts
Two patterns conflict if neither is more specific than the other. Registering conflicting patterns causes a panic.
Host Precedence
Patterns with hosts take precedence over patterns without:
Complete Example
Common Patterns
Resource CRUD
Nested Resources
Special Routes Before Wildcards
Compatibility
For code that relied on pre-1.22 behavior (literal braces in patterns):
Common Mistakes
- Forgetting method prefix -
/posts/{id}matches all methods - Conflicting patterns - causes panic at registration, not runtime
- Missing `{$}` -
/posts/matches/posts/anything, use/posts/{$}for exact match - Wildcard naming -
{id}and{identifier}are different wildcards, name doesn't affect precedence
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingcmd/sgai/skel/.sgai/skills/coding-practices/go-http-server-routes/SKILL.md
Popularity
- Repository stars
- 113
- Repository forks
- 6
- 7-day trend score
- 24
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 27 Mar 2026, 7 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/sandgardenhq/sgai/go-http-server-routes)