teapot-router is an expressive routing layer built on top of chi, inspired by
Laravel's router.
It adds features like named routes, query-based routing, and S3 action context injection, while staying lightweight and Go-idiomatic.
Routes, gently steeped.
- 🍃 Built on
chi— fast, minimal, battle-tested - 🏷 Named routes with reverse URL generation
- 🧭 Laravel-inspired fluent routing API
- 🔍 Query parameter multiplexing — same path routes to different handlers based on query params
- ☁️ S3 action context injection — ideal for S3-compatible APIs
- 🧩 Fully compatible with
chimiddleware
go get github.com/mallardduck/teapot-routerimport (
"net/http"
teapot "github.com/mallardduck/teapot-router"
)
func main() {
r := teapot.New()
r.GET("/users", listUsers).Name("users.index")
r.GET("/users/{id}", showUser).Name("users.show")
http.ListenAndServe(":3000", r)
}Named routes can be reversed into URL paths at any point after registration:
path := r.MustURL("users.show", "id", "42")
// "/users/42"
// Or with error handling:
path, err := r.URL("users.show", "id", "42")Parameters are key-value pairs matching the placeholder names in the pattern.
Wildcard segments ({key:.*}) are substituted the same way.
For more usage details see: docs/USAGE.md
- Prefer clarity over cleverness
- Stay close to
chi, don't replace it - Add expressiveness without becoming a framework
- Make S3-style APIs readable at a glance
MIT ☕