Releases: bmf-san/goblin
Releases · bmf-san/goblin
2.0.0
Support middlewares 🎉
- Supported middlewares
- Refactored a part of router
- Added description of middleware to README.md
Upgrade guide
This version is not backwards compatible and needs to be addressed when updating.
So you need to change the DSL for the routing definition as follows:
r.GET(`/`, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "/")
}))
r.GET(`/`).Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, `/`)
}))
Major changes
New chain methods called Handler
and Use
have been added.
Handler
is required, but Use
is not.
If you want to use middleware, you can set it by using Use
.
func first(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "first: before\n")
next.ServeHTTP(w, r)
fmt.Fprintf(w, "first: after\n")
})
}
r.GET(`/`).Use(first).Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, `/`)
}))
The signature of the method with the same name as the HTTP verb(GET
, POST
, PUT
, PATCH
, DELETE
, OPTION
) has changed.
Before:
GET(path string, handler http.Handler)
After:
GET(path string)
See the README.md and _examples for more specific information.
What's Changed
Full Changelog: 1.2.2...2.0.0
1.2.2
1.2.1
1.2.0
1.1.2
1.1.1
1.1.0
1.0.6
What's Changed
- How about supporting http.Handler instead of just only http.HandlerFunc by @Songmu in #16
- define type regCache to cache regexp by @Songmu in #17
- Fix some comments by @bmf-san in #19
- separate benchmark package to reduce dependency by @Songmu in #18
- Update benchmark tests and readme by @bmf-san in #20
New Contributors
Full Changelog: 1.0.5...1.0.6