https://github.com/jeremyctrl/httprouter
A tiny, fast HTTP router powered by minimal perfect hashes
https://github.com/jeremyctrl/httprouter
http httprouter router
Last synced: about 1 month ago
JSON representation
A tiny, fast HTTP router powered by minimal perfect hashes
- Host: GitHub
- URL: https://github.com/jeremyctrl/httprouter
- Owner: jeremyctrl
- License: mit
- Created: 2025-11-08T00:16:20.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2025-11-15T16:05:30.000Z (3 months ago)
- Last Synced: 2025-11-15T18:09:31.676Z (3 months ago)
- Topics: http, httprouter, router
- Language: Go
- Homepage: https://pkg.go.dev/github.com/jeremyctrl/httprouter
- Size: 13.7 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# httprouter
[](https://pkg.go.dev/github.com/jeremyctrl/httprouter)
[](https://opensource.org/licenses/MIT)
A tiny, fast HTTP router powered by minimal perfect hashes.
`httprouter` is a compact router that compiles route templates into minimal-perfect-hash tables at build time so lookups are constant-time.
## Get
```bash
go get github.com/jeremyctrl/httprouter
```
### Example
```go
package main
import (
"fmt"
"log"
"net/http"
"github.com/jeremyctrl/httprouter"
)
func Index(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
fmt.Fprint(w, "Welcome!\n")
}
func Hello(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
fmt.Fprintf(w, "hello, %s!\n", ps.ByName("name"))
}
func main() {
router := httprouter.New().
GET("/", Index).
GET("/hello/:name", Hello).
Build()
log.Fatal(http.ListenAndServe(":8080", router))
}
```