You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by sp...@apache.org on 2022/01/14 10:28:12 UTC
[apisix] branch master updated: chore: clean core request module (#6108)
This is an automated email from the ASF dual-hosted git repository.
spacewander pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git
The following commit(s) were added to refs/heads/master by this push:
new 77626e0 chore: clean core request module (#6108)
77626e0 is described below
commit 77626e05a1ad7c262307af0c0e62c4d1a41f4b5b
Author: Zeping Bai <bz...@apache.org>
AuthorDate: Fri Jan 14 18:28:06 2022 +0800
chore: clean core request module (#6108)
---
apisix/core/request.lua | 13 +------------
apisix/plugins/opa/helper.lua | 4 ++--
t/core/request.t | 39 +--------------------------------------
3 files changed, 4 insertions(+), 52 deletions(-)
diff --git a/apisix/core/request.lua b/apisix/core/request.lua
index 69ff2fa..c15ac62 100644
--- a/apisix/core/request.lua
+++ b/apisix/core/request.lua
@@ -269,18 +269,7 @@ function _M.get_port(ctx)
end
-function _M.get_path(ctx)
- if not ctx then
- ctx = ngx.ctx.api_ctx
- end
-
- return ctx.var.uri or ''
-end
-
-
-function _M.get_http_version()
- return ngx.req.http_version()
-end
+_M.get_http_version = ngx.req.http_version
_M.get_method = ngx.req.get_method
diff --git a/apisix/plugins/opa/helper.lua b/apisix/plugins/opa/helper.lua
index dc3d12d..abcb44b 100644
--- a/apisix/plugins/opa/helper.lua
+++ b/apisix/plugins/opa/helper.lua
@@ -38,10 +38,10 @@ end
local function build_http_request(conf, ctx)
return {
scheme = core.request.get_scheme(ctx),
- method = core.request.get_method(ctx),
+ method = core.request.get_method(),
host = core.request.get_host(ctx),
port = core.request.get_port(ctx),
- path = core.request.get_path(ctx),
+ path = ctx.var.uri,
headers = core.request.headers(ctx),
query = core.request.get_uri_args(ctx),
}
diff --git a/t/core/request.t b/t/core/request.t
index c12f2f7..f3dba2c 100644
--- a/t/core/request.t
+++ b/t/core/request.t
@@ -445,17 +445,7 @@ the post form is too large: request body in temp file not supported
location = /hello {
content_by_lua_block {
local core = require("apisix.core")
- local ngx_ctx = ngx.ctx
- local api_ctx = ngx_ctx.api_ctx
- if api_ctx == nil then
- api_ctx = core.tablepool.fetch("api_ctx", 0, 32)
- ngx_ctx.api_ctx = api_ctx
- end
-
- core.ctx.set_vars_meta(api_ctx)
-
- local method = core.request.get_method(ngx.ctx.api_ctx)
- ngx.say(method)
+ ngx.say(core.request.get_method())
}
}
--- request
@@ -464,30 +454,3 @@ POST /hello
POST
--- no_error_log
[error]
-
-
-
-=== TEST 14: get_path
---- config
- location /hello1 {
- content_by_lua_block {
- local core = require("apisix.core")
- local ngx_ctx = ngx.ctx
- local api_ctx = ngx_ctx.api_ctx
- if api_ctx == nil then
- api_ctx = core.tablepool.fetch("api_ctx", 0, 32)
- ngx_ctx.api_ctx = api_ctx
- end
-
- core.ctx.set_vars_meta(api_ctx)
-
- local path = core.request.get_path(ngx.ctx.api_ctx)
- ngx.say(path)
- }
- }
---- request
-GET /hello1/test?a=b&b=a
---- response_body
-/hello1/test
---- no_error_log
-[error]