golang-http-frameworks

Go HTTP API development with net/http, Chi, Gin, Echo, and Fiber frameworks

By bobmatnyc · 398 installs

npx skills add bobmatnyc/claude-mpm-skills --skill golang-http-frameworks

Source repository · Upstream listing

Go HTTP Frameworks & REST APIs Overview Go provides exceptional HTTP capabilities starting with the standard library's net/http package. Go 1.22+ introduced enhanced pattern routing in ServeMux , making stdlib viable for many applications. For more complex needs, frameworks like Chi, Gin, Echo, and Fiber offer additional features while maintaining Go's simplicity and performance. Key Features: 🌐 net/http : Production ready standard library with Go 1.22+ routing 🎯 Chi : Lightweight, stdlib compatible router with middleware chains ⚡ Gin : High performance framework with binding and validation 🛡️ Echo : Type safe, enterprise framework with OpenAPI support 🚀 Fiber : Express.js inspired framework with WebSocket support 🔧 Middleware : Composable request/response processing ✅ Validation : Struct tag based request validation 🧪 Testing : httptest.Server for comprehensive integration tests When to Use This Skill Activate this skill when: Building RESTful APIs or web services Choosing appropriate HTTP framework for project requirements Implementing authentication or authorization middleware Designing REST endpoint patterns and validation Testing HTTP handlers and middleware chains Optimizing API performance and response times Migrating between HTTP frameworks Framework Selection Guide net/http (Standard Library) Go 1.22+ Use When: Building simple to moderate complexity APIs Avoiding external dependencies is priority Need maximum compatibility and long term stability Team prefers explicit over implicit patterns Strengths: Zero dependencies, part of Go standard library Go 1.22+ pattern routing with path parameters Excellent performance and stability Extensive ecosystem compatibility No framework lock in Limitations: More verbose middleware composition Manual request validation No built in binding or rendering Example: Chi Lightweight Router Use When: Want stdlib compatible router with better ergonomics Need clean middleware composition Prefer explicit over magic patterns Building moderate to complex routing structures Strengths: 100% compatible with net/http Excellent middleware ecosystem Route grouping and nesting Context based parameter passing Minimal performance overhead Installation: Example: Gin High Performance Framework Use When: Need maximum performance (8x faster than most frameworks) Want batteries included experience Require built in validation and binding Building JSON APIs with minimal boilerplate Strengths: Extremely fast (fastest Go framework in benchmarks) Built in JSON binding and validation Middleware ecosystem Group based routing Custom error handling Installation: Example: Echo Enterprise Framework Use When: Building enterprise applications Need OpenAPI/Swagger integration Want comprehensive middleware library Require type safe routing and binding Strengths: Type safe routing with automatic parameter binding Built in middleware for common patterns OpenAPI/Swagger generation support Excellent error handling middleware WebSocket support Installation: Example: Fiber Express.js Style Use When: Team familiar with Express.js patterns Need WebSocket support out of the box Building real time applications Want fastest route matching performance Strengths: Express.js inspired API (easy for Node.js developers) Fastest route matching (uses fasthttp) Built in WebSocket support Template engine support File upload handling Limitations: Uses fasthttp instead of net/http (less ecosystem compatibility) Not compatible with standard http.Handler interface Slightly less mature ecosystem Installation: Example: Common HTTP Patterns Request Validation Struct Tag Validation: Custom Validators: Middleware Patterns Authentication Middleware: Rate Limiting Middleware: CORS Middleware: Error Handling Strategies Custom Error Types: Error Response Middleware: REST API Design Patterns Resource Naming Conventions: Pagination Pattern: Query Parameter Filtering: HTTP Client Patterns Production Ready HTTP Client: Retry Logic with Exponential Backoff: Testing HTTP Handlers Using httptest.Server: Testing Middleware: Performance Optimization Response Compression: Connection Pooling Configuration: Decision Tree Common Pitfalls Pitfall 1: Not Closing Response Bodies Pitfall 2: Not Using Context for Timeouts Pitfall 3: Ignoring HTTP Status Codes Pitfall 4: Not Reusing HTTP Clients Go Idiomatic Quality Rules Small, high frequency Go idioms worth enforcing in handler/service code: Use := for locals with an initial value — reserve var for zero values and package level declarations. Don't name an unused method receiver — func ( Server) Foo() makes it clear the receiver is irrelevant. Initialize struct pointers with &T{} , not new(T) — consistent with composite literals and lets you set fields inline. Handle (don't discard) returned errors — a dropped error from Decode / Write /a repository call turns a failure into a silent success. See [go idioms quality.md](references/go idioms quality.md) for non idiomatic vs idiomatic examples and how to test/lint each. Most are enforced by gofmt s , staticcheck , errcheck , and revive under golangci lint . Derived from CAST Highlight Go tagged code quality indicators (https://doc.casthighlight.com/), which reference Effective Go and the Go Code Review Comments wiki as primary sources. Related Skills golang testing strategies : Testing HTTP handlers and middleware golang database patterns : Integrating databases with HTTP APIs toolchains typescript frameworks nodejs backend : Comparison with Node.js patterns References [Go net/http Documentation](https://pkg.go.dev/net/http) [Chi Framework](https://go chi.io/) [Gin Framework](https://gin gonic.com/) [Echo Framework](https://echo.labstack.com/) [Fiber Framework](https://gofiber.io/) [Go HTTP Best Practices](https://golang.org/doc/effective go web server)