-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Improve CORS Method Middleware #477
Improve CORS Method Middleware #477
Conversation
It looks like CI is failing on Go < 1.11 due to |
21fd551
to
485bbf3
Compare
12176f8
to
ff3f999
Compare
I've modified the travis CI config to only check the gofmt diff on the latest Go version, let me know if that is undesirable for some reason. |
Good move - no disagreement from me.
Will review in full this week.
…On Mon, May 27, 2019 at 12:19 PM Franklin Harding ***@***.***> wrote:
I've modified the travis CI config to only check the gofmt diff on the
latest Go version, let me know if that is undesirable for some reason.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#477?email_source=notifications&email_token=AAAEQ4C6RRVUZZ66QCIBUEDPXQJ2PA5CNFSM4HPYDHU2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWKHU5I#issuecomment-496269941>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAEQ4BL2FB3QNDRFGCKQMDPXQJ2PANCNFSM4HPYDHUQ>
.
|
Can you summarize the breaking changes / major behavioral changes (same thing) for the change-log, too? |
Sure! I think these are all of them: Breaking changes to
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comments.
As I've reviewed this, my overall feedback is that the .Methods(http.MethodOptions)
requirement will continue to be a sharp edge for users, and we should document it clearly if we are not automatically handling it for them.
c79f90b
to
38f5d51
Compare
* 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
7ca8d93
to
794440e
Compare
Updated the circleci config to only check the gofmt diff on the latest go version like I did for travis originally. Also that github integration with circleci is clean 🙌 |
Thanks! I’ll update the base CI template to do that + run lint where possible too^ ^ A couple of Gorilla packages fail golint due to Http vs. HTTP casing. |
See
https://github.com/gorilla/.github/blob/master/config.yml.tmpl as the
canonical example!
…On Sat, Jun 29, 2019 at 12:16 PM Franklin Harding ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In .circleci/config.yml
<#477 (comment)>:
> @@ -11,8 +11,11 @@ jobs:
- checkout
- run: go version
- run: go get -t -v ./...
- - run: diff -u <(echo -n) <(gofmt -d .)
- - run: if [[ "$LATEST" = true ]]; then go vet -v .; fi
+ - run: >
+ if [[ "$LATEST" = true ]]; then
+ diff -u <(echo -n) <(gofmt -d .)
Good call
—
You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub
<#477?email_source=notifications&email_token=AAAEQ4GHOKIY3FHVWVF4IE3P46YIJA5CNFSM4HPYDHU2YY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOB5BPVSQ#discussion_r298808793>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAEQ4FM24YN4C275OTHZXTP46YIJANCNFSM4HPYDHUQ>
.
|
Thanks again @fharding1! 👍 |
full diff: gorilla/mux@ed099d4...00bdffe changes included: - gorilla/mux#477 Improve CORS Method Middleware - implements gorilla/mux#477 Make CORSMethodMiddleware actually make sense - gorilla/mux#489 Fix nil panic in authentication middleware example Signed-off-by: Sebastiaan van Stijn <[email protected]>
full diff: gorilla/mux@ed099d4...00bdffe changes included: - gorilla/mux#477 Improve CORS Method Middleware - implements gorilla/mux#477 Make CORSMethodMiddleware actually make sense - gorilla/mux#489 Fix nil panic in authentication middleware example Signed-off-by: Sebastiaan van Stijn <[email protected]> Upstream-commit: bb5650619e26cf0b79f30bafc551e5120a0643a4 Component: engine
full diff: gorilla/mux@ed099d4...00bdffe changes included: - gorilla/mux#477 Improve CORS Method Middleware - implements gorilla/mux#477 Make CORSMethodMiddleware actually make sense - gorilla/mux#489 Fix nil panic in authentication middleware example Signed-off-by: Sebastiaan van Stijn <[email protected]> Signed-off-by: zach <[email protected]>
full diff: gorilla/mux@ed099d4...00bdffe changes included: - gorilla/mux#477 Improve CORS Method Middleware - implements gorilla/mux#477 Make CORSMethodMiddleware actually make sense - gorilla/mux#489 Fix nil panic in authentication middleware example Signed-off-by: Sebastiaan van Stijn <[email protected]>
full diff: gorilla/mux@ed099d4...00bdffe changes included: - gorilla/mux#477 Improve CORS Method Middleware - implements gorilla/mux#477 Make CORSMethodMiddleware actually make sense - gorilla/mux#489 Fix nil panic in authentication middleware example Signed-off-by: Sebastiaan van Stijn <[email protected]> Upstream-commit: 4b5ecc982a441b26846c4240c30b03f940950b31 Component: cli
> | ||
< HTTP/1.1 200 OK | ||
< Access-Control-Allow-Methods: GET,PUT,PATCH,OPTIONS | ||
< Access-Control-Allow-Origin: * |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docs added above said
You will still need to use your own CORS handler to set the other CORS headers such as
Access-Control-Allow-Origin
But the example shows that header is added, which is it?
And what's the relationship of this middleware with github.com/gorilla/handlers/CORS?
I'm confused.
This PR implements the behavior outlined in #476:
Access-Control-Allow-Methods
on all requests to a route with an OPTIONS method matcherAccess-Control-Allow-Methods
headerOPTIONS
header toAccess-Control-Allow-Methods
regardless of whether there is an OPTIONS method matcher. Only returnsOPTIONS
if there is an actual matcherCloses #476