change: used response which is a fully name.

This commit is contained in:
Yuansheng Wang 2019-05-23 14:42:42 +08:00
parent ebd046dbdf
commit 0d64f7d1c3
9 changed files with 15 additions and 14 deletions

View File

@ -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

View 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"),

View File

@ -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)

View File

View File

View 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

View File

@ -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")

View File

@ -1,6 +1,7 @@
use t::APISix 'no_plan';
repeat_each(2);
log_level('info');
no_root_location();
run_tests();