-
Notifications
You must be signed in to change notification settings - Fork 505
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
perf(MuxPath): prefix and fullpath support rewrite_target #553
perf(MuxPath): prefix and fullpath support rewrite_target #553
Conversation
Codecov Report
@@ Coverage Diff @@
## main #553 +/- ##
=======================================
Coverage 78.51% 78.51%
=======================================
Files 94 95 +1
Lines 10878 10940 +62
=======================================
+ Hits 8541 8590 +49
- Misses 1850 1867 +17
+ Partials 487 483 -4
Continue to review full report at Codecov.
|
pkg/object/httpserver/mux.go
Outdated
path := ctx.Request().Path() | ||
|
||
if mp.path != "" { | ||
ctx.Request().SetPath(mp.rewriteTarget) | ||
return | ||
} | ||
|
||
if mp.pathPrefix != "" { | ||
path = strings.Replace(path, mp.pathPrefix, mp.rewriteTarget, 1) | ||
ctx.Request().SetPath(path) | ||
return | ||
} | ||
|
||
if mp.pathRE != nil { | ||
path = mp.pathRE.ReplaceAllString(path, mp.rewriteTarget) | ||
ctx.Request().SetPath(path) | ||
return | ||
} |
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.
This is incorrect, for example:
if both mp.path
and mp.pathPrefix
are not empty and the request matches mp.pathPrefix
, the path should be rewritten at L277, but was actually rewritten at L272, which is wrong.
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.
I missed the point that path and prefix and regexp can co-exist, I previously thought they were a mutually exclusive relationship, I'll fix that
This change could be documented here: controllers.md . Old doc
New doc:
|
rule:
|
close: #552