Releases: guregu/kami
Go 1.9 support
Cancel contexts automatically
The net/http
package in the standard library cancels every request's context after it has finished. kami doesn't do this by default for backwards compatibility reasons. Now you can set kami.Cancel
(or mux.Cancel
) to true
to enable behavior like the standard library that cancels contexts automatically.
SetParam
Added kami.SetParam
, this lets you change params you retrieve from kami.Param
.
Params were never intended to be mutable, but this allows you to test handlers without running them through kami (see: #26).
If you use this in middleware or a request, it might have unintended consequences. Also, it isn't concurrency-safe. Please use it for setting up contexts for tests only.
I have experimented with making SetParam safe (safe-params branch) but it makes paths with lots of params slower and increases allocations.
If you have a use case for this, open an issue. However, I think it's a bad idea to mutate the params outside of testing.
Multiple wildcard middlewares
No longer are you restricted to one wildcard middleware/afterware per path.
More middleware types
You can use shorter function signatures like func(http.ResponseWriter, *http.Request) context.Context
as middleware now.
Standard context!
- Supports the standard
context
package. - Remains backwards compatible with the
x/net/context
package. - Middleware will change your
*http.Request
's context and you can use vanilla http.Handler's for read-only middleware.
Somewhat breaking changes in a couple type signatures (LogHandler, ContextHandler, Middleware, Afterware).
Serve methods for Mux
Adds the equivalent of kami.Serve()
and similar methods to *kami.Mux
.
gopkg.in fix
Internal packages don't play well when multiple import paths are acceptable, so I moved some stuff around.
httptreemux
This release replaces httprouter with httptreemux, but maintains the same API.
The routing rules have been significantly relaxed as a result, see Routing Rules.