1.4 KiB
1.4 KiB
ADR-0006: HTTP Framework
Status
Accepted
Context
The platform needs an HTTP framework for:
- REST API endpoints
- Middleware support (auth, logging, metrics)
- Request/response handling
- Route registration from modules
- Integration with observability tools
Options considered:
- gin-gonic/gin - Fast, feature-rich HTTP web framework
- gorilla/mux - Lightweight router
- go-chi/chi - Lightweight, idiomatic router
- net/http (standard library) - No external dependency
Decision
Use gin-gonic/gin (v1.9.1+) as the HTTP framework.
Rationale:
- Fast performance (comparable to net/http)
- Rich middleware ecosystem
- Excellent for REST APIs
- Easy route grouping (useful for modules)
- Good OpenTelemetry integration support
- Widely used and well-documented
- Recommended in playbook-golang.md
Consequences
Positive
- High performance
- Easy middleware chaining
- Route grouping supports module architecture
- Good ecosystem support
Negative
- Additional dependency (though lightweight)
- Slight learning curve for developers unfamiliar with Gin
Implementation Notes
- Install:
go get github.com/gin-gonic/gin@v1.9.1 - Create router in
internal/server/server.go - Use route groups for module isolation:
r.Group("/api/v1/blog") - Add middleware stack: logging, recovery, metrics, auth (later)
- Support graceful shutdown via fx lifecycle