Run route middleware for OPTIONS fallbacks#2978
Open
puneetdixit200 wants to merge 1 commit into
Open
Conversation
This file contains hidden or 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
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.
Overview:
Access-Control-Request-Methodto choose the matched route middleware when handling browser preflights.What problem does it solve?:
Closes #2950. In v5, grouped CORS middleware could be skipped for preflight requests when the group had a matching GET route but no explicit OPTIONS route. The router returned its implicit OPTIONS handler directly, so the CORS middleware never added
Access-Control-Allow-Origin. This keeps the fallback handler but wraps it with the matched route middleware chain, allowing CORS to handle the preflight before the fallback writes the 204 response.Special notes for a reviewer:
Verified with:
GOMODCACHE=/tmp/echo-gomodcache GOCACHE=/tmp/echo-gocache go test ./middleware -run TestCORSWithConfig_GroupPreflightWithoutOptionsRoute -count=1GOMODCACHE=/tmp/echo-gomodcache GOCACHE=/tmp/echo-gocache go test ./...GOMODCACHE=/tmp/echo-gomodcache GOCACHE=/tmp/echo-gocache go vet ./...GOMODCACHE=/tmp/echo-gomodcache GOCACHE=/tmp/echo-gocache go test -race ./...PATH=/tmp/echo-bin:$PATH GOMODCACHE=/tmp/echo-gomodcache GOCACHE=/tmp/echo-gocache staticcheck ./...PATH=/tmp/echo-bin:$PATH GOMODCACHE=/tmp/echo-gomodcache GOCACHE=/tmp/echo-gocache golint -set_exit_status ./...git diff --check