Commit Graph

215 Commits

Author SHA1 Message Date
Matt Silverlock
5bbbb5b2b5 [docs] Add graceful shutdown example (#329) 2018-01-07 07:57:08 -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
Zak Chitty
5ab525f4fb Public test API to set URL params (#322)
* Add a function to set url params for test

* [docs] add justification for SetURLVars and description of alternative approach to setting url vars.
* rename SetURLParams to SetURLVars as this is more descriptive.
* rename testing to testing_helpers as this is more descriptive.

* [docs] add stipulation to SetURLVars that it should only be used for testing purposes
2017-12-08 08:08:15 -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
Matt Silverlock
c572efe429 [docs] Note StrictSlash re-direct behaviour #308 (#321)
* [docs] Note StrictSlash re-direct behaviour #308

* StrictSlash enabled routes return a 301 to the client
* As per the HTTP standards, non-idempotent methods, such as POST or PUT, will be followed with a GET by the client
* Users should use middleware if they wish to change this behaviour to return a HTTP 308.

* Update description of StrictSlash
2017-12-02 12:38:52 -08:00
Matt Silverlock
65ec7248c5 Create ISSUE_TEMPLATE.md (#318) 2017-11-28 16:00:09 -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
Chris Dostert
2d5fef06b8 [docs] fix outdated UseEncodedPath method docs (#314)
https://github.com/gorilla/mux/pull/306 changed UseEncodedPath to use native go encoded path handling so cautions in it's docs are no longer applicable.
2017-11-08 19:54:02 -08:00
Roberto Santalla
7f08801859 MatchErr is set to ErrNotFound if NotFoundHandler is used (#311) v1.6.0 2017-11-05 09:23:20 -08:00
Kamil Kisiel
9f48112f18 [docs] Document router.Match (#313)
* Document router.Match

The return values are getting confusing. Hopefully this helps.

* Simplify some language.

* Remove double the
2017-11-04 21:08:26 -07:00
Matt Silverlock
bc452d92e3 [build] Allow tip failures (#312)
[build] Allow tip failures
2017-11-04 13:51:27 -07:00
Kamil Kisiel
7625a85c14 .travis.yml: Remove versions < go1.5 from build matrix 2017-10-19 20:47:00 -07:00
Mike Busch
c9183aaddd use req.URL.EscapedPath() instead of getPath(req) (#306)
This change drops support of go < 1.5. go1.5 has been officially
unsupported since go1.7 was released 2016/08/15.
2017-10-19 20:46:20 -07: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
Adam Ouellette
9bd9ff2d1d Added 1.9 build step (#303) 2017-10-10 14:54:56 -07:00
Pontus Leitzler
bdd5a5a1b0 Fix WriteHeader in TestA301ResponseWriter. (#301)
WriteHeader did only set status field for a local copy that was discared
upon return.
2017-10-08 14:49:13 -07:00
Matthew Riley
3f19343c7d [docs] Document evaluation order for routes (#297) 2017-09-22 13:54:14 -07:00
Stephan Renatus
24fca303ac [docs] README.md: add missing . (#292) v1.5.0 2017-09-05 10:10:44 -07:00
Matt Silverlock
bb285ea687 [docs] Fix missing space in docstring (#289) 2017-08-30 13:57:41 -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
Cody Oss
8c683ee571 Fix typo 2017-06-21 15:07:33 -07:00
Chris Hines
18fca31550 Add test and fix for escaped query values.
Reproduces and fixes #238.
2017-06-02 12:31:40 -07:00
Chris Hines
c7a138dbc1 Update docs. 2017-06-02 12:31:40 -07:00
Pavel Ivanov
f9aa23a02b Add tests for support for queries in URL reversing. 2017-06-02 12:31:40 -07:00
Pavel Ivanov
9c9af153a1 Add support for queries in URL reversing. 2017-06-02 12:31:40 -07:00
Nick Hudkins
043ee6597c Update Walking Routes Section
Fixed invalid method chaining.
2017-05-23 18:01:04 -07:00
Nick Hudkins
59ce66852b Fix invalid example code
In the "List Routes" example code, `.HandleFunc` was being called on a `*mux.Route` rather than `*mux.Router`. Updated the example code to work :)
2017-05-23 18:01:04 -07:00
Brian Michel
85b8c203a4 Removing half of conflict marker (#268)
Looks like there was just part of a conflict marker in the README file, so I figured I'd remove it.
2017-05-22 19:46:13 -07:00
Nick Miyake
456bcfa82d Update README with example for Router.Walk 2017-05-22 08:17:48 -07:00
Nick Miyake
4d814f7650 Update ancestors parameter for WalkFunc for matcher subrouters
Fixes #263
2017-05-22 08:17:48 -07:00
Nick Miyake
a322b2c2ec Update Walk to match all subrouters
Matches all routes instead of just routes with paths.

Fixes #261
2017-05-21 14:35:07 -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.
v1.4.0
2017-05-20 21:50:13 -07:00
Bulat Gaifullin
751308a60a Updated README 2017-05-20 15:55:46 -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
Carlos Alexandro Becker
4c1c3952b7 fixed typo (#250) 2017-04-26 21:12:50 -07:00
Diego Siqueira
599cba5e7b Fixing Regexp in the benchmark test (#234)
Signed-off-by: DiSiqueira <dieg0@live.com>
2017-02-28 14:43:54 -08:00
Shane Smith-Sahnow
ad4ce0eb16 updating logic in route matcher, cleaner and saner (#235) 2017-02-27 19:44:49 -08:00
Kamil Kisiel
999ef73f5d Merge pull request #232 from DavidJFelix/patch-1
Add sourcegraph badge
2017-02-23 12:25:54 -08:00
David J. Felix
89d16fe9a0 Add sourcegraph badge
Fixes #228
2017-02-23 14:57:28 -05:00
Kamil Kisiel
94e7d24fd2 Add Go 1.8 to .travis.yml 2017-02-17 11:26:16 -08:00
Adam Eijdenberg
392c28fe23 [bugfix] fail fast if regex is incorrectly specified using capturing groups. (#218) v1.3.0 2017-01-18 05:43:44 -08:00
Shawn Smith
cafdb65e9e [docs] Add route listing example to README
* Update README.md

* Update README.md
2017-01-18 05:43:23 -08:00
Kamil Kisiel
b12896167c Merge pull request #199 from wirehead/minor-doc-tweek
Clarify how route variables work. (#151)
v1.2.0
2017-01-16 23:01:07 -08:00
Kamil Kisiel
34dda716af Merge pull request #215 from ShaneSaww/fix_for_subroutes_with_pathPrefix
Adding in a check for routes with just /
2017-01-16 22:41:11 -08:00
ShaneSaww
b9ff34f617 Adding some extra tests, to hit all the use cases 2017-01-16 21:11:35 -08:00
ShaneSaww
293ebe1493 Adding in a check for routes with just / 2017-01-15 21:47:00 -08:00
Ken Wronkiewicz
910dd3aa31 Remove unnecessary line from example
Review comment: setting the header complicates things.
2016-10-03 15:30:11 -07:00