Skip to content

Releases: yousuf64/shift

v0.5.0

31 Dec 14:36
Compare
Choose a tag to compare

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() or Params.Map() and use the break keyword:
        • Example 1: for _, param := range route.Params.Slice() { ... }.
        • Example 2: for k, v := range route.Params.Map() { ... }.
      • For cases where it always returned true, you can now simply remove the return true.
  • 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 the SliceHeader implementation.
    • Even though now it is a non-pointer, it's still precautionary to copy the Params using Params.Copy() before using it in another Goroutine / using it beyond the request lifecycle.

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 to os.Stdout. To write to a different destination, a new RecoverWithWriter middleware is provided.
  • It's no longer needed for the RouteContext middleware to precede the Recover middleware to minimize allocations.
  • Exposed Key and Value fields in the Param struct (returned by Params.Slice()).
  • Fixed issue where calling Params.Slice() and Params.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

19 Dec 10:01
1488125
Compare
Choose a tag to compare
v0.5.0-rc3 Pre-release
Pre-release

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() or Params.Map() and use the break keyword:
        • Example 1: for _, param := range route.Params.Slice() { ... }.
        • Example 2: for k, v := range route.Params.Map() { ... }.
      • For cases where it always returned true, you can now simply remove the return true.
  • 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 the SliceHeader implementation.
    • Even though now it is a non-pointer, it's still precautionary to copy the Params using Params.Copy() before using it in another Goroutine / using it beyond the request lifecycle.

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 to os.Stdout. To write to a different destination, a new RecoverWithWriter middleware is provided.
  • It's no longer needed for the RouteContext middleware to precede the Recover middleware to minimize allocations.
  • Exposed Key and Value fields in the Param struct (returned by Params.Slice()).
  • Fixed issue where calling Params.Slice() and Params.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

08 Apr 09:15
Compare
Choose a tag to compare

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).
  • * 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

27 Mar 16:24
Compare
Choose a tag to compare

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.

v0.2.1

26 Mar 07:04
Compare
Choose a tag to compare

README and GitHub Actions changes

v0.2.0

18 Mar 11:25
Compare
Choose a tag to compare

beta release

v0.1.2

18 Mar 11:34
Compare
Choose a tag to compare
v0.1.2 Pre-release
Pre-release

beta release