-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
CORS: add an optional custom function to validate the origin #1651
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1651 +/- ##
==========================================
+ Coverage 84.72% 84.88% +0.15%
==========================================
Files 29 29
Lines 1938 1945 +7
==========================================
+ Hits 1642 1651 +9
+ Misses 188 187 -1
+ Partials 108 107 -1
Continue to review full report at Codecov.
|
Codecov appears broken, it's saying coverage was reduced by 284 lines in files completely unrelated to the change. See also this 3 line |
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.
LGTM
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 use case looks valid to me.
I also do not see any breaking changes. Tests look ok, if you can think of further useful tests.
Would you mind providing a PR with a code example in https://github.com/labstack/echox too.
That would complete the change and help others with an example.
@lammel thanks the review. I have implemented your feedback and opened a PR here labstack/echox#164 to document the feature. Could you please have a look? |
Seems I was too eager merging another CORS related issue first. |
Done! The diff looks weird for some reason but the code change is the same as before. |
c94a119
to
e6f24aa
Compare
Merged. Thanks @dahu33 ! |
The CORS middleware is great and works very well if the list of allowed origins is static. However, in many use cases, this list need to be dynamic (for example, if coming from the database). This is a non-breaking change that makes the CORS middleware accepting an optional custom function to validate the origin.
PS: the diff looks weird for some unknown reason but the code change is minimal (mostly indentation).
Thanks!