-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
feat: support variable when rewrite header in proxy rewrite plugin #9112
feat: support variable when rewrite header in proxy rewrite plugin #9112
Conversation
apisix/core/utils.lua
Outdated
local resolve_var_with_captures | ||
do | ||
local _captures | ||
-- escape is not supported very well, like there si a redundant '\' after escape "$1" |
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.
-- escape is not supported very well, like there si a redundant '\' after escape "$1" | |
-- escape is not supported very well, like there is a redundant '\' after escape "$1" |
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.
Done
apisix/plugins/proxy-rewrite.lua
Outdated
if not m then | ||
if err then | ||
core.log.error("match error in proxy-rewrite plugin, please check: ", err) | ||
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.
Do we need to return a 503 for this error?
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 prefer 500, it's an unexpected condition
apisix/plugins/proxy-rewrite.lua
Outdated
|
||
local m, err = re_match(upstream_uri, conf.regex_uri[1], "jo") | ||
if not m then | ||
if err then |
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.
We can merge the two conditions above?
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.
how? use the re_match
first, then use the match result to replace?
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.
See #9112 (comment)
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.
Done
Description
Support for referencing the match result of the
regex_uri
when rewrite header in the proxy-rewrite plugin, and the match result can be referenced as a variable by other plugins too.Nginx:
Apisix:
Checklist