Skip to content
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 allow regex pattern #1623

Merged
merged 1 commit into from
Sep 1, 2020
Merged

cors allow regex pattern #1623

merged 1 commit into from
Sep 1, 2020

Conversation

KlotzAndrew
Copy link
Contributor

enable cors to use regex pattern for allowed origins

implementation is similar to another popular cors middleware: https://github.com/astaxie/beego/blob/master/plugins/cors/cors.go#L196-L201

@codecov
Copy link

codecov bot commented Aug 18, 2020

Codecov Report

Merging #1623 into master will increase coverage by 0.12%.
The diff coverage is 88.88%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1623      +/-   ##
==========================================
+ Coverage   85.08%   85.20%   +0.12%     
==========================================
  Files          28       28              
  Lines        2185     2203      +18     
==========================================
+ Hits         1859     1877      +18     
  Misses        212      212              
  Partials      114      114              
Impacted Files Coverage Δ
middleware/cors.go 79.45% <88.88%> (+3.08%) ⬆️
middleware/util.go 90.62% <0.00%> (+6.25%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8dd25c3...9a28fb8. Read the comment docs.

enable cors to use regex pattern for allowed origins

implementation is similar to another popular cors
middleware: https://github.com/astaxie/beego/blob/master/plugins/cors/cors.go#L196-L201
Copy link
Contributor

@lammel lammel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good.
A small performance penalty is expected for CORS checks due to the regex matching used.

Tests available to check for plaintext and regex matches.

@lammel lammel merged commit bcb3165 into labstack:master Sep 1, 2020
@lammel
Copy link
Contributor

lammel commented Sep 1, 2020

@KlotzAndrew Thanks for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants