wklken commented on code in PR #9720:
URL: https://github.com/apache/apisix/pull/9720#discussion_r1241213085
##########
apisix/plugins/mocking.lua:
##########
@@ -49,7 +49,19 @@ local schema = {
-- specify response json schema, if response_example is not nil, this
conf will be ignore.
-- generate random response by json schema.
response_schema = { type = "object" },
- with_mock_header = { type = "boolean", default = true }
+ with_mock_header = { type = "boolean", default = true },
+ headers = {
Review Comment:
The name `headers` and its placement just below `with_mock_header` can
create confusion as to whether these two keys are related.
- `headers` to `response_headers`?
- add comment `-- specify response headers.`
##########
apisix/plugins/mocking.lua:
##########
@@ -215,6 +227,12 @@ function _M.access(conf, ctx)
ngx.header["x-mock-by"] = "APISIX/" .. core.version.VERSION
end
+ if conf.headers then
+ for key, value in pairs(conf.headers) do
+ core.log.warn(key, value, "dibag")
+ core.response.add_header(key, value)
Review Comment:
1. remove the core.log.warn?
2. use `ngx.header[key] = value` instead? keep the same as line 227
--
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]