Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
=== TEST 1: set route(id: 1)
--- 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,
[[{
"methods": ["GET"],
"upstream": {
"nodes": {
"127.0.0.1:1980": 1
},
"type": "roundrobin"
},
"host": "foo.com",
"uri": "/h{:.*}"
}]]
)
if code >= 300 then
ngx.status = code
end
ngx.say(body)
}
}
--- request
GET /t
--- response_body
passed
--- no_error_log
[error]
=== TEST 2: hit routes
--- request
GET /hello
--- more_headers
Host: foo.com
--- response_body
hello world
--- no_error_log
[error]
=== TEST 3: not found
--- request
GET /world
--- more_headers
Host: foo.com
--- error_code: 404
--- no_error_log
[error]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment