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 bf603ac51 feat(admin): add head method support to /apisix/admin (#8752)
bf603ac51 is described below
commit bf603ac517e890f2b67c726cc40a66edc58fd8f2
Author: dongjunduo <[email protected]>
AuthorDate: Wed Feb 15 09:54:46 2023 +0800
feat(admin): add head method support to /apisix/admin (#8752)
---
apisix/admin/init.lua | 10 ++++++++++
t/admin/api.t | 18 ++++++++++++++++++
2 files changed, 28 insertions(+)
diff --git a/apisix/admin/init.lua b/apisix/admin/init.lua
index e96b05c33..1c139ef7f 100644
--- a/apisix/admin/init.lua
+++ b/apisix/admin/init.lua
@@ -130,6 +130,11 @@ local function strip_etcd_resp(data)
end
+local function head()
+ core.response.exit(200)
+end
+
+
local function run()
local api_ctx = {}
core.ctx.set_vars_meta(api_ctx)
@@ -365,6 +370,11 @@ end
local uri_route = {
+ {
+ paths = [[/apisix/admin]],
+ methods = {"HEAD"},
+ handler = head,
+ },
{
paths = [[/apisix/admin/*]],
methods = {"GET", "PUT", "POST", "DELETE", "PATCH"},
diff --git a/t/admin/api.t b/t/admin/api.t
index d7fff64df..67d7344b6 100644
--- a/t/admin/api.t
+++ b/t/admin/api.t
@@ -138,3 +138,21 @@ X-API-KEY: edd1c9f034335f136f87ad84b625c8f1
--- response_headers
X-API-VERSION: v2
--- response_body_like: "/apisix/routes"
+
+
+
+=== TEST 9: Head method support for admin API
+--- config
+ location /t {
+ content_by_lua_block {
+ local t = require("lib.test_admin").test
+ local code, body = t('/apisix/admin',
+ ngx.HTTP_HEAD)
+ ngx.status = code
+ ngx.say(body)
+ }
+ }
+--- request
+GET /t
+--- response_body
+passed