mirror of
https://gitee.com/iresty/apisix.git
synced 2024-12-12 11:55:28 +08:00
fix(admin): modify boolean parameters with PATCH (#5434)
This commit is contained in:
parent
9caf9f1865
commit
cd29ba3be7
@ -157,7 +157,7 @@ local function run()
|
||||
|
||||
if req_body then
|
||||
local data, err = core.json.decode(req_body)
|
||||
if not data then
|
||||
if err then
|
||||
core.log.error("invalid request body: ", req_body, " err: ", err)
|
||||
core.response.exit(400, {error_msg = "invalid request body: " .. err,
|
||||
req_body = req_body})
|
||||
|
@ -247,7 +247,7 @@ function _M.patch(id, conf, sub_path, args)
|
||||
return 400, {error_msg = "missing route id"}
|
||||
end
|
||||
|
||||
if not conf then
|
||||
if conf == nil then
|
||||
return 400, {error_msg = "missing new configuration"}
|
||||
end
|
||||
|
||||
|
82
t/admin/routes3.t
vendored
82
t/admin/routes3.t
vendored
@ -700,3 +700,85 @@ passed
|
||||
}
|
||||
--- response_body
|
||||
passed
|
||||
|
||||
|
||||
|
||||
=== TEST 20: set route(id: 1, parameters with boolean values)
|
||||
--- config
|
||||
location /t {
|
||||
content_by_lua_block {
|
||||
local t = require("lib.test_admin").test
|
||||
local code, body = t('/apisix/admin/routes/1',
|
||||
ngx.HTTP_PUT,
|
||||
[[{
|
||||
"uri": "/index.html",
|
||||
"enable_websocket": true,
|
||||
"upstream": {
|
||||
"type": "roundrobin",
|
||||
"nodes": {
|
||||
"127.0.0.1:8080":1
|
||||
}
|
||||
}
|
||||
}]])
|
||||
|
||||
ngx.say(body)
|
||||
}
|
||||
}
|
||||
--- response_body
|
||||
passed
|
||||
|
||||
|
||||
|
||||
=== TEST 21: patch route(modify the boolean value of parameters to false)
|
||||
--- config
|
||||
location /t {
|
||||
content_by_lua_block {
|
||||
local t = require("lib.test_admin").test
|
||||
local code, body = t('/apisix/admin/routes/1/enable_websocket',
|
||||
ngx.HTTP_PATCH,
|
||||
'false',
|
||||
[[{
|
||||
"node": {
|
||||
"value": {
|
||||
"enable_websocket": false
|
||||
},
|
||||
"key": "/apisix/routes/1"
|
||||
},
|
||||
"action": "compareAndSwap"
|
||||
}]]
|
||||
)
|
||||
|
||||
ngx.status = code
|
||||
ngx.say(body)
|
||||
}
|
||||
}
|
||||
--- response_body
|
||||
passed
|
||||
|
||||
|
||||
|
||||
=== TEST 22: patch route(modify the boolean value of parameters to true)
|
||||
--- config
|
||||
location /t {
|
||||
content_by_lua_block {
|
||||
local t = require("lib.test_admin").test
|
||||
local code, body = t('/apisix/admin/routes/1/enable_websocket',
|
||||
ngx.HTTP_PATCH,
|
||||
'true',
|
||||
[[{
|
||||
"node": {
|
||||
"value": {
|
||||
"enable_websocket": true
|
||||
},
|
||||
"key": "/apisix/routes/1"
|
||||
},
|
||||
"action": "compareAndSwap"
|
||||
}]]
|
||||
)
|
||||
|
||||
ngx.status = code
|
||||
ngx.say(body)
|
||||
}
|
||||
}
|
||||
--- response_body
|
||||
passed
|
||||
|
Loading…
Reference in New Issue
Block a user