Releases: yousuf64/shift
Releases Β· yousuf64/shift
v0.5.0
Breaking Changes
Params.ForEach(cb)
: now the callback doesn't have a return type.- Previously, the iteration was interrupted by returning
false
from the callback. While this could be useful, it is unidiomatic and introduces additional boilerplate. - To address this, the return type has been removed from the callback signature for simplicity.
- Migration:
- For cases requiring interruption or short-circuiting, it is recommended to iterate over
Params.Slice()
orParams.Map()
and use thebreak
keyword:- Example 1:
for _, param := range route.Params.Slice() { ... }
. - Example 2:
for k, v := range route.Params.Map() { ... }
.
- Example 1:
- For cases where it always returned
true
, you can now simply remove thereturn true
.
- For cases requiring interruption or short-circuiting, it is recommended to iterate over
- Previously, the iteration was interrupted by returning
Route.Params
is changed from a pointer to a non-pointer.- This is to prevent
Route.Params
from being modified through pointer dereference:- Previously, bad Params could sneak into the Params pool, resulting in corrupt behavior.
- Also, emptyParams could be replaced, which could creep into all the static request handlers.
- With this change,
Route.Params
stores data in a backing*internalParams
object. This design is inspired by theSliceHeader
implementation. - Even though now it is a non-pointer, it's still precautionary to copy the
Params
usingParams.Copy()
before using it in another Goroutine / using it beyond the request lifecycle.
- This is to prevent
Enhancements & Fixes
- Used new methods provided in the
unsafe
package with Go 1.20 for efficient byte-to-string conversion (Go 1.18 and above are still supported through build constraints). Recover
middleware no longer responds with the stack trace. Instead, stack track is written toos.Stdout
. To write to a different destination, a newRecoverWithWriter
middleware is provided.- It's no longer needed for the
RouteContext
middleware to precede theRecover
middleware to minimize allocations. - Exposed
Key
andValue
fields in theParam
struct (returned byParams.Slice()
). - Fixed issue where calling
Params.Slice()
andParams.Map()
from a static route causes a panic. - Fixed issue #9.
Full changelog: v0.4.0...v0.5.0
In addition, there will likely be other breaking/behavior changes before the 1.0.0 release as we standardize the API.
v0.5.0-rc3
Breaking Changes
Params.ForEach(cb)
: now the callback doesn't have a return type.- Previously, the iteration was interrupted by returning
false
from the callback. While this could be useful, it is unidiomatic and introduces additional boilerplate. - To address this, the return type has been removed from the callback signature for simplicity.
- Migration:
- For cases requiring interruption or short-circuiting, it is recommended to iterate over
Params.Slice()
orParams.Map()
and use thebreak
keyword:- Example 1:
for _, param := range route.Params.Slice() { ... }
. - Example 2:
for k, v := range route.Params.Map() { ... }
.
- Example 1:
- For cases where it always returned
true
, you can now simply remove thereturn true
.
- For cases requiring interruption or short-circuiting, it is recommended to iterate over
- Previously, the iteration was interrupted by returning
Route.Params
is changed from a pointer to a non-pointer.- This is to prevent
Route.Params
from being modified through pointer dereference:- Previously, bad Params could sneak into the Params pool, resulting in corrupt behavior.
- Also, emptyParams could be replaced, which could creep into all the static request handlers.
- With this change,
Route.Params
stores data in a backing*internalParams
object. This design is inspired by theSliceHeader
implementation. - Even though now it is a non-pointer, it's still precautionary to copy the
Params
usingParams.Copy()
before using it in another Goroutine / using it beyond the request lifecycle.
- This is to prevent
Enhancements & Fixes
- Used new methods provided in the
unsafe
package with Go 1.20 for efficient byte-to-string conversion (Go 1.18 and above are still supported through build constraints). Recover
middleware no longer responds with the stack trace. Instead, stack track is written toos.Stdout
. To write to a different destination, a newRecoverWithWriter
middleware is provided.- It's no longer needed for the
RouteContext
middleware to precede theRecover
middleware to minimize allocations. - Exposed
Key
andValue
fields in theParam
struct (returned byParams.Slice()
). - Fixed issue where calling
Params.Slice()
andParams.Map()
from a static route causes a panic. - Fixed issue #9.
Full changelog: v0.4.0...v0.5.0-rc3
In addition, there will likely be other breaking/behavior changes before the 1.0.0 release as we standardize the API.
v0.4.0
Notable changes:
- Prevent matching URLs with empty parameter values.
- Example:
/posts//comments
will no longer match/posts/:id/comments
as the:id
value is empty).
- Example:
- * When executing a handler matched from case insensitive search,
- It keeps the original request's path as it is. (Earlier, it was setting the correct URL to the request path before passing it into the handler)
- It sets the matched handler's path template to
Route.Path
.
- Fixes issue #6 and #7.
- Fixes the issue where multiple instances of Router sharing common configs.
Full changelog: v0.3.0...v0.4.0
Changes marked with (*) are major behavior changes. In addition, there will likely be other breaking/behavior changes before the 1.0.0 release as we standardize the API.
v0.3.0
Notable changes:
- Router.Base() and Router.Routes() is moved to Group struct. So now those methods are accessible via both Group and Router; since Router embeds the Group struct.
- Group.Routes() returns the routes registered for the group, whereas Router.Routes() returns all the registered routes.
- Router.RoutesScoped() is removed as the same behavior is achieved when calling Group.Routes() after the changes.
Full changelog: v0.2.1...v0.3.0
Some of the above changes are breaking changes. In addition, there will likely be other breaking changes before the 1.0.0 release as we standardize the API.