Skip to content

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.

2 participants