Allow header support in Router, MethodNotFoundHandler (405) and CORS middleware#2039
Merged
aldas merged 2 commits intolabstack:masterfrom Jan 3, 2022
Merged
Allow header support in Router, MethodNotFoundHandler (405) and CORS middleware#2039aldas merged 2 commits intolabstack:masterfrom
Allow header support in Router, MethodNotFoundHandler (405) and CORS middleware#2039aldas merged 2 commits intolabstack:masterfrom
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2039 +/- ##
==========================================
+ Coverage 91.32% 91.57% +0.24%
==========================================
Files 33 33
Lines 2871 2919 +48
==========================================
+ Hits 2622 2673 +51
+ Misses 159 157 -2
+ Partials 90 89 -1
Continue to review full report at Codecov.
|
Contributor
Author
|
@lammel when you have time. please review. |
Contributor
|
Working on it... so many lines to review ;-)
Martti T. ***@***.***> schrieb am So., 5. Dez. 2021, 18:35:
… @lammel <https://github.com/lammel> when you have time. please review.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2039 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAKVHUTUACCGXVWWVWZSTTUPOPFPANCNFSM5JL7GEXQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
lammel
reviewed
Dec 6, 2021
Contributor
lammel
left a comment
There was a problem hiding this comment.
Didn't have time to run or check on the tests yet, but code is mostly reviewed now an LGTM.
lammel
approved these changes
Dec 9, 2021
Contributor
lammel
left a comment
There was a problem hiding this comment.
Fine piece of coding work. LGTM!
3 tasks
3 tasks
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.
This PR adds support for
Allowheader toAllowheader lists all method types registered for given routed url path.Related RFCs:
AllowRFC https://datatracker.ietf.org/doc/html/rfc7231#section-7.4.1 all 405 should haveAllowheader listing all methods that router has registered for given path.Allowis optional but useful header to haveImplementation notes:
next(c)and hope to meet our router optionshandler we probably not succeed because of different kinds of authentication middlewares (ala JWT or BasicAuth or KeyAuth) which check for stuff like that.Allowvalue to contextecho.ContextKeyHeaderAllowis because default 405 handler needs to be able to access that value and possibly CORS middleware is interested in that value. Asecho.MethodNotAllowedHandleris part of public API we can not change how that method is created due backwards compatibility.optionsMethodHandleris kept private as it is router specific implementation detail. If you want your own then you can add them withe.OPTIONS()method for paths you choose.Using context values in Echo core is so far unprecedented and potentially controversial decision. I did not want to introduce new field into
echo.contextstruct as it is quite specific case and I know that Go standard libraryhttp.Serveris usingcontext.Contextto add some info to each request context - so it is not so unheard of but probably should be avoided:See:
Let's have a discussion