moonming commented on code in PR #7554:
URL: https://github.com/apache/apisix/pull/7554#discussion_r931848410
##########
apisix/plugins/key-auth.lua:
##########
@@ -90,12 +93,28 @@ end
function _M.rewrite(conf, ctx)
local from_header = true
- local key = core.request.header(ctx, conf.header)
+ local key
+
+ if conf.var_combination then
+ local err, n_resolved
+ key, err, n_resolved = core.utils.resolve_var(conf.var_combination,
ctx.var)
+ if err then
+ core.log.error("could not resolve vars in ",
+ conf.var_combination, " error: ", err)
+ end
+
+ if n_resolved == 0 then
+ key = nil
+ end
Review Comment:
```suggestion
if err then
core.log.error("could not resolve vars in ",
conf.var_combination, " error: ", err)
elseif n_resolved == 0 then
key = nil
end
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]