mirror of
https://gitee.com/iresty/apisix.git
synced 2024-12-02 20:17:35 +08:00
change: used response
which is a fully name.
This commit is contained in:
parent
ebd046dbdf
commit
0d64f7d1c3
@ -37,14 +37,14 @@ function _M.rewrite_phase()
|
||||
ngx_ctx.api_ctx = api_ctx
|
||||
end
|
||||
|
||||
local method = core.ctx.get(api_ctx, "method")
|
||||
local uri = core.ctx.get(api_ctx, "uri")
|
||||
-- local host = core.ctx.get(api_ctx, "host") -- todo: support host
|
||||
local method = core.ctx.get_var(api_ctx, "method")
|
||||
local uri = core.ctx.get_var(api_ctx, "uri")
|
||||
-- local host = core.ctx.get_var(api_ctx, "host") -- todo: support host
|
||||
|
||||
local ok = router():dispatch(method, uri, api_ctx)
|
||||
if not ok then
|
||||
core.log.info("not find any matched route")
|
||||
return core.resp.say(404)
|
||||
return core.response.say(404)
|
||||
end
|
||||
|
||||
-- todo: move those code to another single file
|
||||
|
@ -49,7 +49,7 @@ return {
|
||||
clear = require("table.clear"),
|
||||
nkeys = require("table.nkeys"),
|
||||
},
|
||||
resp = require("apisix.core.resp"),
|
||||
response = require("apisix.core.response"),
|
||||
typeof = require("apisix.core.typeof"),
|
||||
lrucache = require("apisix.core.lrucache"),
|
||||
ctx = require("apisix.core.ctx"),
|
||||
|
@ -13,7 +13,7 @@ local var_methods = {
|
||||
}
|
||||
|
||||
|
||||
function _M.get(api_ctx, name)
|
||||
function _M.get_var(api_ctx, name)
|
||||
local vars = api_ctx.vars
|
||||
if not vars then
|
||||
vars = new_tab(0, 8)
|
||||
|
0
lua/apisix/core/request.lua
Normal file
0
lua/apisix/core/request.lua
Normal file
0
lua/apisix/plugins/key-auth.lua
Normal file
0
lua/apisix/plugins/key-auth.lua
Normal file
@ -27,7 +27,7 @@ function _M.access(conf, ctx)
|
||||
local limit_ins = core.lrucache.plugin_ctx(plugin_name, ctx,
|
||||
create_limit_obj, conf)
|
||||
|
||||
local key = core.ctx.get(ctx, conf.key)
|
||||
local key = core.ctx.get_var(ctx, conf.key)
|
||||
if not key or key == "" then
|
||||
key = ""
|
||||
core.log.warn("fetched empty string value as key to limit the request ",
|
||||
@ -38,15 +38,15 @@ function _M.access(conf, ctx)
|
||||
if not delay then
|
||||
local err = remaining
|
||||
if err == "rejected" then
|
||||
return core.resp.say(conf.rejected_code)
|
||||
return core.response.say(conf.rejected_code)
|
||||
end
|
||||
|
||||
core.log.error("failed to limit req: ", err)
|
||||
return core.resp.say(500)
|
||||
return core.response.say(500)
|
||||
end
|
||||
|
||||
core.resp.set_header("X-RateLimit-Limit", conf.count)
|
||||
core.resp.set_header("X-RateLimit-Remaining", remaining)
|
||||
core.response.set_header("X-RateLimit-Limit", conf.count)
|
||||
core.response.set_header("X-RateLimit-Remaining", remaining)
|
||||
|
||||
core.log.info("hit limit-count access")
|
||||
end
|
||||
|
@ -25,7 +25,7 @@ function _M.access(conf, ctx)
|
||||
local limit_ins = core.lrucache.plugin_ctx(plugin_name, ctx,
|
||||
create_limit_obj, conf)
|
||||
|
||||
local key = core.ctx.get(ctx, conf.key)
|
||||
local key = core.ctx.get_var(ctx, conf.key)
|
||||
if not key or key == "" then
|
||||
key = ""
|
||||
core.log.warn("fetched empty string value as key to limit the request ",
|
||||
@ -35,11 +35,11 @@ function _M.access(conf, ctx)
|
||||
local delay, err = limit_ins:incoming(key, true)
|
||||
if not delay then
|
||||
if err == "rejected" then
|
||||
return core.resp.say(conf.rejected_code)
|
||||
return core.response.say(conf.rejected_code)
|
||||
end
|
||||
|
||||
core.log.error("failed to limit req: ", err)
|
||||
return core.resp.say(500)
|
||||
return core.response.say(500)
|
||||
end
|
||||
|
||||
core.log.info("hit limit-req access")
|
||||
|
@ -1,6 +1,7 @@
|
||||
use t::APISix 'no_plan';
|
||||
|
||||
repeat_each(2);
|
||||
log_level('info');
|
||||
no_root_location();
|
||||
|
||||
run_tests();
|
||||
|
Loading…
Reference in New Issue
Block a user