mirror of
https://gitee.com/iresty/apisix.git
synced 2024-12-05 05:27:35 +08:00
feature: supported to patch whole route content.
This commit is contained in:
parent
19e09b539f
commit
77e5b50591
@ -1,6 +1,7 @@
|
||||
local core = require("apisix.core")
|
||||
local schema_plugin = require("apisix.admin.plugins").check_schema
|
||||
local tostring = tostring
|
||||
local type = type
|
||||
|
||||
|
||||
local _M = {
|
||||
@ -198,7 +199,11 @@ function _M.patch(id, conf, sub_path)
|
||||
end
|
||||
|
||||
local sub_name = sub_paths[#sub_paths]
|
||||
sub_value[sub_name] = conf
|
||||
if sub_name and sub_name ~= "" then
|
||||
sub_value[sub_name] = conf
|
||||
else
|
||||
node_value = conf
|
||||
end
|
||||
core.log.info("new conf: ", core.json.delay_encode(node_value, true))
|
||||
|
||||
local id, err = check_conf(id, node_value, true)
|
||||
|
@ -16,17 +16,17 @@ __DATA__
|
||||
content_by_lua_block {
|
||||
local t = require("lib.test_admin").test
|
||||
local code, body = t('/apisix/admin/routes/1',
|
||||
ngx.HTTP_PUT,
|
||||
[[{
|
||||
"methods": ["GET"],
|
||||
"upstream": {
|
||||
"nodes": {
|
||||
"127.0.0.1:8080": 1
|
||||
},
|
||||
"type": "roundrobin"
|
||||
ngx.HTTP_PUT,
|
||||
[[{
|
||||
"methods": ["GET"],
|
||||
"upstream": {
|
||||
"nodes": {
|
||||
"127.0.0.1:8080": 1
|
||||
},
|
||||
"desc": "new route",
|
||||
"uri": "/index.html"
|
||||
"type": "roundrobin"
|
||||
},
|
||||
"desc": "new route",
|
||||
"uri": "/index.html"
|
||||
}]],
|
||||
[[{
|
||||
"node": {
|
||||
@ -1036,3 +1036,55 @@ GET /t
|
||||
passed
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
||||
|
||||
|
||||
=== TEST 30: patch route(whole)
|
||||
--- config
|
||||
location /t {
|
||||
content_by_lua_block {
|
||||
local t = require("lib.test_admin").test
|
||||
local code, body = t('/apisix/admin/routes/1/',
|
||||
ngx.HTTP_PATCH,
|
||||
[[{
|
||||
"methods": ["GET"],
|
||||
"upstream": {
|
||||
"nodes": {
|
||||
"127.0.0.1:8080": 1
|
||||
},
|
||||
"type": "roundrobin"
|
||||
},
|
||||
"desc": "new route",
|
||||
"uri": "/index.html"
|
||||
}]],
|
||||
[[{
|
||||
"node": {
|
||||
"value": {
|
||||
"methods": [
|
||||
"GET"
|
||||
],
|
||||
"uri": "/index.html",
|
||||
"desc": "new route",
|
||||
"upstream": {
|
||||
"nodes": {
|
||||
"127.0.0.1:8080": 1
|
||||
},
|
||||
"type": "roundrobin"
|
||||
}
|
||||
},
|
||||
"key": "/apisix/routes/1"
|
||||
},
|
||||
"action": "set"
|
||||
}]]
|
||||
)
|
||||
|
||||
ngx.status = code
|
||||
ngx.say(body)
|
||||
}
|
||||
}
|
||||
--- request
|
||||
GET /t
|
||||
--- response_body
|
||||
passed
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
Loading…
Reference in New Issue
Block a user