-
Notifications
You must be signed in to change notification settings - Fork 92
feat : excluede paths by regex #36
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
Conversation
handler.go
Outdated
@@ -73,5 +73,5 @@ func (g *gzipHandler) shouldCompress(req *http.Request) bool { | |||
return false | |||
} | |||
|
|||
return !g.ExcludedPaths.Contains(req.URL.Path) | |||
return !g.ExcludedPaths.Contains(req.URL.Path) && !g.ExcludedPathesRegexs.Contains(req.URL.Path) |
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.
suggestion use if statement
options.go
Outdated
@@ -5,6 +5,8 @@ import ( | |||
"net/http" | |||
"strings" | |||
|
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.
remove the empty line and fmt it
@@ -36,6 +39,11 @@ func WithExcludedPaths(args []string) Option { | |||
o.ExcludedPaths = NewExcludedPaths(args) | |||
} | |||
} | |||
func WithExcludedPathsRegexs(args []string) Option { |
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.
add empty line.
} | ||
return result | ||
} | ||
func (e ExcludedPathesRegexs) Contains(requestURI string) bool { |
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.
add empty line
handler.go
Outdated
@@ -72,6 +72,11 @@ func (g *gzipHandler) shouldCompress(req *http.Request) bool { | |||
if g.ExcludedExtensions.Contains(extension) { | |||
return false | |||
} | |||
|
|||
return !g.ExcludedPaths.Contains(req.URL.Path) | |||
if !g.ExcludedPaths.Contains(req.URL.Path) { |
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.
add an empty line between if block.
@standcats build fails? |
Codecov Report
@@ Coverage Diff @@
## master #36 +/- ##
===========================================
- Coverage 97.56% 84.84% -12.72%
===========================================
Files 3 3
Lines 82 99 +17
===========================================
+ Hits 80 84 +4
- Misses 1 12 +11
- Partials 1 3 +2
Continue to review full report at Codecov.
|
@appleboy |
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
Waiting for @thinkerou approval. |
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, thanks!
Proposal
Allow regular expressions to exclude paths.
Gin can specify parameters in the URL.
In this case, the action name may be specified below the parameter.
The current exclusion doesn't allow you to specify a lower parameter, so I'd like to add it.
exp: