https://github.com/sanae10001/go-simple-middleware
Simple go http middleware
https://github.com/sanae10001/go-simple-middleware
body-limit go go-middleware jwt negroni negroni-middleware
Last synced: 6 months ago
JSON representation
Simple go http middleware
- Host: GitHub
- URL: https://github.com/sanae10001/go-simple-middleware
- Owner: sanae10001
- License: mit
- Created: 2017-12-04T07:34:51.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-01-12T09:08:12.000Z (over 8 years ago)
- Last Synced: 2025-08-15T16:44:56.230Z (11 months ago)
- Topics: body-limit, go, go-middleware, jwt, negroni, negroni-middleware
- Language: Go
- Homepage:
- Size: 13.7 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# negroni-middlewares
Simple go http middleware
Support [negroni](https://github.com/urfave/negroni) and standard http library
- [x] Basic auth
- [x] Body limit
- [x] Request id
- [x] JWT
#### Example
*jwt*:
``` go
func main() {
h := func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("OK"))
}
j := jwt.New(jwt.Config{SigningKey: []byte("asecretsigningstring")})
mux := http.NewServeMux()
mux.Handle("/", j.Handler(http.HandlerFunc(h)))
http.ListenAndServe(":8080", mux)
}
```
*jwt for negroni*
```go
func main() {
h := func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("OK"))
}
j := jwt.New(jwt.Config{SigningKey: []byte("asecretsigningstring")})
mux := http.NewServeMux()
mux.HandleFunc("/", h)
n := negroni.New()
n.UseFunc(j.HandlerWithNext)
n.UseHandler(mux)
http.ListenAndServe(":8080", n)
}
```