forked from gorilla/mux
-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🤖 Update from upstream repository gorilla/mux #4
Open
traefiker
wants to merge
90
commits into
containous:master
Choose a base branch
from
gorilla:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[build] Allow tip failures
* Document router.Match The return values are getting confusing. Hopefully this helps. * Simplify some language. * Remove double the
#306 changed UseEncodedPath to use native go encoded path handling so cautions in it's docs are no longer applicable.
* 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
* [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
* Add example usage for Route.HeadersRegexp * Improve example_route_test.go style
* 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
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.
Addresses #294 (comment)
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.
* [docs] Clarify SetURLVars Clarify in documentation that SetURLVars does not modify the given *htttp.Request, provide an example of usage. * Short and sweet function doc, example test.
* Create authentication middleware example. For #339 * Fix example test filename.
* Modify http status code to variable * Modify doc
* Modify http status code to variable * Modify doc * Modify README
Enables neater syntax when chaining several middleware functions.
Prior to this change, the example documentation found in the README.md has an errant code which won't work in the table-driven code example. This change modifies the variable name from `t` to `tc` so it does not conflict with the `t *testing.T` struct definition. * Adds a range clause to the `for` statement * Modifies `for` statement scope to use `tc.shouldPass`, and `tc.routeVariable` Doc: https://github.com/gorilla/mux#testing-handlers
CORSMethodMiddleware sets the Access-Control-Allow-Methods response header on a request, by matching routes based only on paths. It also handles OPTIONS requests, by settings Access-Control-Allow-Methods, and then returning without calling the next HTTP handler.
The example in the README does not pass the request through a mux therefore the request variables from the path are never populated. Update the sample to create a minimum viable router to use. Fixes #373
* More sensical CORSMethodMiddleware * Only sets Access-Control-Allow-Methods on valid preflight requests * Does not return after setting the Access-Control-Allow-Methods header * Does not append OPTIONS header to Access-Control-Allow-Methods regardless of whether there is an OPTIONS method matcher * Adds tests for the listed behavior * Add example for CORSMethodMiddleware * Do not check for preflight and add documentation to the README * Use http.MethodOptions instead of "OPTIONS" * Add link to CORSMethodMiddleware section to readme * Add test for unmatching route methods * Rename CORS Method Middleware to Handling CORS Requests in README * Link CORSMethodMiddleware in README to godoc * Break CORSMethodMiddleware doc into bullets for readability * Add comment about specifying OPTIONS to example in README for CORSMethodMiddleware * Document cURL command used for testing CORS Method Middleware * Update comment in example to "Handle the request" * Add explicit comment about OPTIONS matchers to CORSMethodMiddleware doc * Update circleci config to only check gofmt diff on latest go version * Break up gofmt and go vet checks into separate steps. * Use canonical circleci config
* Update config.yml * Update config.yml
No need to convert here.
Use a single append call instead of a ranged for loop.
* Add documentation for using mux to serve a SPA * r -> router to prevent shadowing * Expand SPA acronym * BrowserRouter link * Add more comments to explain how the spaHandler.ServeHTTP method works
* Guess the scheme if r.URL.Scheme is unset It's not expected that the request's URL is fully populated when used on the server-side (it's more of a client-side field), so we shouldn't expect it to be present. In practice, it's only rarely set at all on the server, making mux's `Schemes` matcher tricky to use as it is. This commit adds a test which would have failed before demonstrating the problem, as well as a fix which I think makes `.Schemes` match what users expect. * [doc] Add more detail to Schemes and URL godocs * Add route url test for schemes * Make httpserver test use more specific scheme matchers * Update test to have different responses per route
* Remove context helpers in context.go * Update request context funcs to take concrete types * Move TestNativeContextMiddleware to mux_test.go * Clarify KeepContext Go 1.7+ comment Mux doesn't build on Go < 1.7 so the comment doesn't really need to clarify anymore.
* Adds a test case for the repro given in issue #534 * Fixes the logic in CORSMethodMiddleware to handle matching routes better
Fix the CORSMethodMiddleware bug with subrouters
A production server is seeing a significant amount of allocations in (*routeRegexp).getURLQuery Since it is only interested in a single value and only the first value we create a specialized function for that. Comparing a few parameter parsing scenarios: ``` Benchmark_findQueryKey/0-8 7184014 168 ns/op 0 B/op 0 allocs/op Benchmark_findQueryKey/1-8 5307873 227 ns/op 48 B/op 3 allocs/op Benchmark_findQueryKey/2-8 1560836 770 ns/op 483 B/op 10 allocs/op Benchmark_findQueryKey/3-8 1296200 931 ns/op 559 B/op 11 allocs/op Benchmark_findQueryKey/4-8 666502 1769 ns/op 3 B/op 1 allocs/op Benchmark_findQueryKeyGoLib/0-8 1740973 690 ns/op 864 B/op 8 allocs/op Benchmark_findQueryKeyGoLib/1-8 3029618 393 ns/op 432 B/op 4 allocs/op Benchmark_findQueryKeyGoLib/2-8 461427 2511 ns/op 1542 B/op 24 allocs/op Benchmark_findQueryKeyGoLib/3-8 324252 3804 ns/op 1984 B/op 28 allocs/op Benchmark_findQueryKeyGoLib/4-8 69348 14928 ns/op 12716 B/op 130 allocs/op ```
Comment for CurrentRoute claimed that setting the KeepContext option would propagate the Route even after the request. The KeepContext option is deprecated and has no effect.
Continuing from PR #447 we have to add extra check to ignore the port as well add tests to cover this case
* build: CircleCI 2.1 + build matrix * build: drop Go 1.9 & Go 1.10 * build: remove erroneous version
* Update README.md * build: gofmt on latest
* regexp: use iota instead of hardcoded values
…ile (#693) * initial commit * fix `README.md` - authenticationMiddleware initialization
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The repository gorilla/mux has some new changes that aren't in this fork.
🤖💬 Done with ❤️ by 🐜 Myrmica Gallienii 🐜