https://github.com/i2bskn/dispatch
HTTP request multiplexer
https://github.com/i2bskn/dispatch
go http mux
Last synced: 8 months ago
JSON representation
HTTP request multiplexer
- Host: GitHub
- URL: https://github.com/i2bskn/dispatch
- Owner: i2bskn
- License: mit
- Created: 2016-10-15T08:38:38.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-03-25T01:21:22.000Z (almost 9 years ago)
- Last Synced: 2025-03-21T16:19:53.110Z (11 months ago)
- Topics: go, http, mux
- Language: Go
- Homepage:
- Size: 47.9 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# dispatch
[](https://godoc.org/github.com/i2bskn/dispatch)
[](https://travis-ci.org/i2bskn/dispatch)
[](https://codecov.io/gh/i2bskn/dispatch)
dispatch is HTTP request multiplexer compatible with `ServeMux` of `net/http`.
## Dependencies
- [Go](https://golang.org/) 1.7 or lator
No dependency on the third party library.
## Installation
```
go get -u github.com/i2bskn/dispatch
```
## Usage
```Go
package main
import (
"fmt"
"log"
"net/http"
"github.com/i2bskn/dispatch"
)
func hello(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello %s!", dispatch.Param(r, "name"))
}
func main() {
mux := dispatch.New()
mux.HandleFunc("/hello/:name", hello)
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, "Home!")
})
log.Fatal(http.ListenAndServe(":8080", mux))
}
```
See also [GoDoc](https://godoc.org/github.com/i2bskn/dispatch).
## License
dispatch is available under the MIT.