https://github.com/harshvladha/hasty
Simple and Fast Multiplexer for Go! (Inspired from github.com/go-zoo/bone)
https://github.com/harshvladha/hasty
go golang hasty multiplexer mux router routing
Last synced: 5 months ago
JSON representation
Simple and Fast Multiplexer for Go! (Inspired from github.com/go-zoo/bone)
- Host: GitHub
- URL: https://github.com/harshvladha/hasty
- Owner: harshvladha
- License: mit
- Created: 2017-02-22T16:28:19.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2019-06-19T10:14:27.000Z (almost 7 years ago)
- Last Synced: 2025-08-14T07:54:47.234Z (10 months ago)
- Topics: go, golang, hasty, multiplexer, mux, router, routing
- Language: Go
- Homepage:
- Size: 19.5 KB
- Stars: 9
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
hasty [](http://godoc.org/github.com/harshvladha/hasty) [](https://goreportcard.com/report/harshvladha/hasty) [](https://sourcegraph.com/github.com/harshvladha/hasty?badge)
=====
Hasty is Simple and Fast Multiplexer for Go language! It supports:
- URL Parameters
- Router Prefix
- Http method declaration
- Support for `http.Handler` and `http.HandlerFunc`
- Custom NotFound handler
### Example
``` go
package main
import (
"net/http"
"encoding/json"
"github.com/harshvladha/hasty"
)
func main() {
mux := hasty.New()
// mux.Get, Post, Put, etc... takes http.Handler
mux.Get("/test", http.HandlerFunc(getHandler))
// :var1 is a path variable
mux.Get("/test/:var1", http.HandlerFunc(getHandler))
mux.ListenAndServe("8080")
}
func getHandler(rw http.ResponseWriter, req *http.Request) {
var queryId string
// Get the value of var1 path variable
if query := hasty.GetValue(req, "var1"); query != "" {
queryId = query
}
var myJson = struct {
First string
Second string
Third string
}{"Hello", "World!", queryId}
json.NewEncoder(rw).Encode(&myJson)
}
```
### Contributing
- Fork it
- Create issue on harshvladha/hasty
- Create your feature/issue related branch (git checkout -b my-new-feature)
- **Write Unit Tests**
- Commit your changes (git commit -am 'Added some feature, Reference to issue.') e.g., Added xyz feature, resolves #1
- Push to the branch (git push origin my-new-feature)
- Create new Pull Request
### License
MIT