https://github.com/livebud/mux
A minimal but feature-rich HTTP router for Go
https://github.com/livebud/mux
Last synced: 4 months ago
JSON representation
A minimal but feature-rich HTTP router for Go
- Host: GitHub
- URL: https://github.com/livebud/mux
- Owner: livebud
- License: mit
- Created: 2023-08-07T07:14:51.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2026-01-25T20:34:46.000Z (5 months ago)
- Last Synced: 2026-01-26T11:54:58.075Z (5 months ago)
- Language: Go
- Homepage:
- Size: 156 KB
- Stars: 34
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: Readme.md
- Changelog: Changelog.md
- License: License.md
Awesome Lists containing this project
README
# Mux
[](https://pkg.go.dev/github.com/livebud/mux)
A minimal but feature-rich HTTP router for Go. A viable alternative to [gorilla/mux](http://github.com/gorilla/mux).
## Features
- Trie-based router for better performance
- Supports required, optional, regexp and wildcard slots
- Smart slot delimiters (e.g. can match `/{from}-{to}`)
- Well-tested with 100s of tests
## Install
```sh
go get github.com/livebud/mux
```
## Example
```go
package main
import (
"net/http"
"github.com/livebud/mux"
)
func main() {
handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(r.URL.Path))
})
router := mux.New()
router.Get("/", handler)
router.Get("/users/{id}", handler)
router.Post("/users/{id}.{format}", handler)
router.Get("/posts/{post_id}/comments/{id}", handler)
router.Get("/fly/{from}-{to}", handler)
router.Get("/v{major|[0-9]+}.{minor|[0-9]+}", handler)
router.Get("/{owner}/{repo}/{branch}/{path*}", handler)
http.ListenAndServe(":3000", router)
}
```
## Contributors
- Matt Mueller ([@mattmueller](https://twitter.com/mattmueller))
## License
MIT