Commit Graph

53 Commits

Author SHA1 Message Date
Souvik Haldar
8559a4f775 [docs] typo (#454) 2019-02-17 07:38:49 -08:00
Gregor Weckbecker
08e7f807d3 Ignore ErrNotFound while matching Subrouters (#438)
MatchErr is set by the router to ErrNotFound if no route matches. If
no route of a Subrouter matches the error can by safely ignored. This
implementation only ignores these errors and does not ignore other
errors like ErrMethodMismatch.
2019-01-08 08:29:30 -06:00
tomare
ef912dd76e [bugfix] Clear matchErr when traversing subrouters.
Previously, when searching for a match, matchErr would be erroneously set, and prevent middleware from running (no match == no middleware runs).

This fix clears matchErr before traversing the next subrouter in a multi-subrouter router.
2018-12-27 16:42:16 -08:00
Joe Wilner
758eb64354 Improve subroute configuration propagation #422
* Pull out common shared `routeConf` so that config is pushed on to child
routers and routes.
* Removes obsolete usages of `parentRoute`
* Add tests defining compositional behavior
* Exercise `copyRouteConf` for posterity
2018-12-07 09:48:26 -06:00
Kamil Kisiel
815b8c6a26 Clarify behaviour of Name method if called multiple times. 2018-08-07 00:50:18 -07:00
Matt Silverlock
e3702bed27 [docs] Improve docstrings for middleware, skipclean (#375) 2018-05-12 20:22:33 -07:00
Matt Silverlock
ded0c29b24 Fix linter issues (docs) (#370) 2018-04-30 20:11:36 -07:00
Kamil Kisiel
077b44c2cf [docs] Document route.Get* methods consistently (#338)
They actually return an error instead of an empty list. `GetMethods` happened to not return an error, but it should for consistency, so I added that as well.
2018-01-19 20:51:41 -08:00
Kamil Kisiel
512169e5d7 refactor routeRegexp, particularily newRouteRegexp. (#328)
The existing options matchPrefix, matchHost, and matchQueries are
mutually exclusive so there's no point in having a separate boolean
argument for each one. It's clearer if there's a single type variable.

strictSlash and useEncodedPath were also being passed as naked bools so
I've wrapped these in a struct called routeRegexpOptions for more clarity
at the call site.
2018-01-05 10:40:59 -08:00
Matthew
7904d2e42e [docs] Add example usage for Route.HeadersRegexp (#320)
* Add example usage for Route.HeadersRegexp

* Improve example_route_test.go style
2017-12-04 08:11:14 -08:00
Matthew
4a3d4f3dd2 [bugfix] Fix method subrouter handler matching (#300) (#317)
* Test method-based subrouters for multiple matching paths

* Pass TestMethodsSubrouter

* Change http.Method* constants to string literals
- Make compatible with Go v1.5

* Make TestMethodsSubrouter stateless and concurrent

* Remove t.Run and break up tests for concurrency

* Use backticks to remove quote escaping

* Remove global method handlers and HTTP method constants
2017-11-28 11:51:17 -08:00
Roberto Santalla
7f08801859 MatchErr is set to ErrNotFound if NotFoundHandler is used (#311) 2017-11-05 09:23:20 -08:00
Paul B. Beskow
10490f55fa GetQueryTemplates and GetQueryRegexp extraction (#304)
Developers can now extract the query templates and regexps
from a router as lists of combined query pairs.
2017-10-19 18:19:04 -07:00
Mayank Patel
a659b61323 Fix #271: Return 405 instead of 404 when request method doesn't match the route 2017-08-29 22:39:17 -07:00
Chris Hines
ac112f7d75 Prefer scheme on child route when building URLs. 2017-07-04 00:43:45 -07:00
Chris Hines
37b3a6cace Use scheme from parent router when building URLs. 2017-07-04 00:43:45 -07:00
Pavel Ivanov
9c9af153a1 Add support for queries in URL reversing. 2017-06-02 12:31:40 -07:00
Chris Hines
bcd8bc72b0 Support building URLs with non-http schemes. (#260)
* Move misplaced tests and fix comments.

* Support building URLs with non-http schemes.

- Capture first scheme configured for a route for use when building
  URLs.
- Add new Route.URLScheme method similar to URLHost and URLPath.
- Update Route.URLHost and Route.URL to use the captured scheme if
  present.

* Remove Route.URLScheme method.

* Remove UTF-8 BOM.
2017-05-20 21:50:13 -07:00
Bulat Gaifullin
b552615e22 Added method Route.GetMethods 2017-05-20 15:55:46 -07:00
Bulat Gaifullin
1856953e53 Added method Route.GetPathRegexp 2017-05-20 15:55:46 -07:00
Shane Smith-Sahnow
ad4ce0eb16 updating logic in route matcher, cleaner and saner (#235) 2017-02-27 19:44:49 -08:00
ShaneSaww
293ebe1493 Adding in a check for routes with just / 2017-01-15 21:47:00 -08:00
Kush Mansingh
0a192a1931 Add useEncodedPath option to router and routes (#190)
- Resolves a breaking change in #184
2016-09-02 08:33:43 -07:00
Jingwen Owen Ou
05d9d908e7 Add SkipClean() to *Route 2016-05-02 10:24:47 -07:00
Jingwen Owen Ou
786d36e5ab go fmt 2016-03-07 11:43:49 -08:00
Dave Newman
8ac5cf967f Add SkipClean option
By default paths are run through the cleanPath method which prevents
using fancier paths like /fetch/http://xkcd.com/534

This adds a SkipClean option so that this path isn't redirected to
/fetch/http/xkcd.com/534
2016-03-07 11:41:38 -08:00
Matt Silverlock
147a95f5e3 Merge pull request #104 from Digitalxero/method-to-get-url-template
[feature] GetHostTemplate and GetPathTemplate return the template used to build the route.
2016-03-05 05:56:38 -08:00
Dj Gilcrease
f7ac7251e3 Update doc strings based on feedback 2016-02-29 07:54:15 -08:00
Matt Silverlock
02c98b3f73 [docs] Satisfied golint.
- SkipRouter should also be ErrRouterSkipped (or similar) but a change would
  break the public API.
2016-02-28 19:32:22 -08:00
Dj Gilcrease
0d60c4bfeb Add tests for GetPathTemplate. Added GetHostTemplate and associated tests as well 2016-02-28 14:42:09 -08:00
Dj Gilcrease
16507e2c47 Merge branch 'master' into method-to-get-url-template 2016-02-28 13:16:25 -08:00
Kamil Kisiel
49c0242755 Merge pull request #125 from eastwood/develop
Fixed documentation from Issue 16
2015-09-08 09:58:39 -07:00
Clint Ryan
8ae7a23e03 Fixed documentation from Issue 16 2015-09-08 21:31:30 +10:00
Kamil Kisiel
b0b2bc47bc Quote domain names in README.md. Use example.com instead of domain.com
Fixes #119
2015-08-13 12:01:04 -07:00
Kamil Kisiel
f15e0c4946 Merge pull request #100 from eastwood/master
Issue #16: Added regex support for matching headers
2015-07-27 09:40:50 -07:00
Dj Gilcrease
8eb02a9f12 Add URLPathTemplate to Route to make it easier to generate a API page that lists all routes by template 2015-07-08 09:47:01 -07:00
Bay Dodd
a710a8bfa9 adding ^ and $ to query pattern 2015-07-05 12:49:02 +01:00
Craig Jellick
c0a5cbce5a Fix typo
Issue #16: Added regex support for matching headers

Issue #16 : Addressed code review and refactored support for regex into
a separate function

Added compiled regex to route matcher
2015-07-05 20:15:55 +10:00
Craig Jellick
77f424d3ae Fix typo 2015-05-29 14:16:30 -07:00
Kamil Kisiel
8a875a034c Merge pull request #52 from sqs/BuildVarsFunc
BuildVarsFunc: modify route variables before building the URL from a route
2015-02-13 11:22:55 -08:00
Peter Waller
8f1a419c38 Remove blank line to fix docs for Route.Queries
The presence of a blank line was preventing the documentation from appearing in godoc.
2014-08-11 15:45:39 +01:00
Raphael Simon
451fd8b779 Additional code cleanup (see comments on issue #56) 2014-05-27 16:37:30 -07:00
Raphael Simon
3505396fb5 Code cleanup (see comments on issue #56) 2014-05-27 11:36:15 -07:00
Raphael Simon
69237eaae5 Fix "Queries" matcher to support out-of-order query string parameters 2014-05-27 09:34:08 -07:00
Raphael Simon
0a0d6a1b2a Add tests for regexp variables in query strings
Fix how regular expression gets built for query string so that order of parameters is always preserved
2014-05-26 20:20:14 -07:00
Raphael Simon
65cc9b5df8 Add ability to capture variables in query strings 2014-05-26 15:01:42 -07:00
Quinn Slack
a883d5a9b9 Call parent BuildVarsFuncs 2014-04-23 11:44:16 -07:00
Quinn Slack
cef3b0cd6d Add BuildVarsFunc to allow modifying route variables before generating a route's URL 2014-04-23 11:44:16 -07:00
Thomas ten Cate
b864f07c53 Propagate StrictSlash to subrouters instead of rudely turning it off 2014-04-23 19:53:35 +02:00
Thomas ten Cate
033224c12e Document behaviour of StrictSlash and PathPrefix better, and add tests to nail this down 2014-04-23 18:19:14 +02:00