Skip to content

Releases: dimfeld/httptreemux

Minor performance improvement to wildcard parsing

14 Sep 05:37
Compare
Choose a tag to compare

The wildcard token parser now uses strings.IndexByte instead of a for loop when finding the next slash. The implementation of IndexByte in previous versions of Go was slow on short strings, but this has been corrected in Go 1.7.

Performance is pretty much unchanged for short tokens, and a few percent faster for long tokens.

Support http.HandlerFunc with Request.Context for parameters on Go 1.7+

13 Sep 18:50
Compare
Choose a tag to compare

With Go 1.7+, there is now the option to store the parameters map inside Request.Context and use Go's standard http.HandlerFunc type for your handler functions. When doing this, theparams map may be accessed using the httptreemux.ContextParams(ctx) function.

The original handler type, with params as an argument to the handler function, is still the default, so all existing code will continue working without changes. To use the new mode, the UsingContext() function will return a version of the mux set up to use the new handler style.

Many thanks to @patrickrand for making this happen!

Optionally add escaped versions of routes

04 Aug 22:42
Compare
Choose a tag to compare

This can be useful when you need to support escaped characters and switching to URL.Path is not an option. Set router.EscapeAddedRoutes to true to use this.

As of this version, releases will be prefixed with 'v' for proper semver compatibility.

Allow * and : in path segments.

31 Mar 20:22
Compare
Choose a tag to compare

The router now allows path segments containing asterisks and colons that are not wildcards. A * or : at the beginning of a path segment must be backslash escaped, like so: router.GET("\\*asteriskpath", handler). The backslash should not be included if it occurs anywhere else in the path, e.g. router.GET("aaa*bbb", handler) as it only checks at the beginning.

Breaking Changes

  • The router no longer panics if you add a path segment containing : or * in the middle of the segment.
  • Path segments starting with two backslashes will be unescaped to start with a single backslash. That is, router.GET("\\\\abc") should now be router.GET("\\\\\\abc").

Search for less specific routes when the best match doesn't handle the request's method

19 Mar 18:06
Compare
Choose a tag to compare

When a node is found but it does not handle the requested HTTP method, look for a less specific match in the rest of the tree that does handle that method.

This also changes the behavior of HeadCanUseGet, which is now checked at route add time instead of at request time. This means that if you are setting HeadCanUseGet to false, you must do so before adding your routes.

Due to the above change, the default MethodNotAllowed handler now includes HEAD in the list of allowed methods, as it should have all along.

Both of these are breaking changes compared to the previous release, but in most cases existing code should not need to change to accommodate them.

Allow adding handler at root of subgroup without a slash

17 Feb 23:18
Compare
Choose a tag to compare
Merge pull request #25 from dbudworth/master

Add ability to map root of subgroup

Enforce that path components have leading slashes

09 Feb 20:22
Compare
Choose a tag to compare

This ensures that subgroups function as expected, rather than mashing together path components that are supposed to be separate. Thanks again to @dbudworth!

Duplicate code refactoring

07 Feb 19:32
Compare
Choose a tag to compare

No change in functionality, just cleaner code layout by putting a default Group into the TreeMux object. Thanks to @bontibon for submitting this!

Add router group functionality

27 Dec 02:41
Compare
Choose a tag to compare

This creates an object that looks like the router object, but prefixes a given path to all paths passed to it. Thanks to @dbudworth for submitting this PR!

Added option for global OPTIONS method handler.

08 Dec 22:57
Compare
Choose a tag to compare