change: responsed a better tip when failed to match any route. (#1013)

This commit is contained in:
YuanSheng Wang 2020-01-03 10:11:37 +08:00 committed by GitHub
parent d4442ff6a7
commit 9e98773fae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 105 additions and 117 deletions

View File

@ -268,7 +268,7 @@ function _M.http_access_phase()
local route = api_ctx.matched_route
if not route then
return core.response.exit(404)
return core.response.exit(404, {error_msg = "failed to match any routes"})
end
if route.value.service_protocol == "grpc" then

View File

@ -158,7 +158,7 @@ function _M.match(api_ctx)
end
core.log.info("not find any matched route")
return core.response.exit(404)
return true
end

View File

@ -98,7 +98,7 @@ function _M.match(api_ctx)
if not uri_router then
core.log.error("failed to fetch valid `uri` router: ")
return core.response.exit(404)
return true
end
core.table.clear(match_opts)
@ -110,7 +110,7 @@ function _M.match(api_ctx)
local ok = uri_router:dispatch(api_ctx.var.uri, match_opts, api_ctx)
if not ok then
core.log.info("not find any matched route")
return core.response.exit(404)
return true
end
return true

View File

@ -84,8 +84,8 @@ passed
--- request
GET /not_found
--- error_code: 404
--- response_body eval
qr/404 Not Found/
--- response_body
{"error_msg":"failed to match any routes"}
--- no_error_log
[error]

View File

@ -93,8 +93,8 @@ passed
--- request
GET /not_found
--- error_code: 404
--- response_body eval
qr/404 Not Found/
--- response_body
{"error_msg":"failed to match any routes"}
--- no_error_log
[error]
@ -104,8 +104,8 @@ qr/404 Not Found/
--- request
GET /hello
--- error_code: 404
--- response_body eval
qr/404 Not Found/
--- response_body
{"error_msg":"failed to match any routes"}
--- no_error_log
[error]

View File

@ -64,8 +64,8 @@ passed
--- request
GET /not_found
--- error_code: 404
--- response_body eval
qr/404 Not Found/
--- response_body
{"error_msg":"failed to match any routes"}
--- no_error_log
[error]
@ -77,8 +77,8 @@ GET /hello
--- more_headers
Host: not_found.com
--- error_code: 404
--- response_body eval
qr/404 Not Found/
--- response_body
{"error_msg":"failed to match any routes"}
--- no_error_log
[error]

View File

@ -56,8 +56,8 @@ qr/"value":"mexxxxxxxxxxxxxxx"/
--- request
GET /not_found
--- error_code: 404
--- response_body_like eval
qr/404 Not Found/
--- response_body
{"error_msg":"failed to match any routes"}
--- grep_error_log eval
qr/\[error\].*/
--- grep_error_log_out eval

View File

@ -57,8 +57,8 @@ qr/"value":"mexxxxxxxxxxxxxxx"/
--- request
GET /not_found
--- error_code: 404
--- response_body_like eval
qr/404 Not Found/
--- response_body
{"error_msg":"failed to match any routes"}
--- grep_error_log eval
qr/\[error\].*/
--- grep_error_log_out eval

View File

@ -56,8 +56,8 @@ qr/"value":"mexxxxxxxxxxxxxxx"/
--- request
GET /not_found
--- error_code: 404
--- response_body_like eval
qr/404 Not Found/
--- response_body
{"error_msg":"failed to match any routes"}
--- grep_error_log eval
qr/\[error\].*/
--- grep_error_log_out eval

View File

@ -102,8 +102,8 @@ passed
--- request
GET /not_found
--- error_code: 404
--- response_body eval
qr/404 Not Found/
--- response_body
{"error_msg":"failed to match any routes"}
--- no_error_log
[error]

View File

@ -57,7 +57,7 @@ passed
--- request
GET /hello
--- error_code: 404
--- response_body_like eval
--- response_body eval
qr/404 Not Found/
--- wait_etcd_sync: 0.3
--- grep_error_log eval

View File

@ -67,8 +67,8 @@ passed
--- request
GET /not_found
--- error_code: 404
--- response_body_like eval
qr/404 Not Found/
--- response_body
{"error_msg":"failed to match any routes"}
--- no_error_log
[error]

View File

@ -77,8 +77,8 @@ location /t {
}
--- request
GET /t
--- response_body_like eval
qr{.*404 Not Found.*}
--- response_body eval
qr/"error_msg":"failed to match any routes"/
--- no_error_log
[error]
@ -89,8 +89,8 @@ qr{.*404 Not Found.*}
--- request
GET /not_found
--- error_code: 404
--- response_body_like eval
qr{.*404 Not Found.*}
--- response_body eval
qr/"error_msg":"failed to match any routes"/
--- no_error_log
[error]
@ -129,7 +129,7 @@ close: 1 nil
--- request
GET /hello
--- error_code: 404
--- response_body_like eval
qr{.*404 Not Found.*}
--- response_body
{"error_msg":"failed to match any routes"}
--- no_error_log
[error]

View File

@ -61,8 +61,8 @@ passed
--- request
GET /not_found
--- error_code: 404
--- response_body eval
qr/404 Not Found/
--- response_body
{"error_msg":"failed to match any routes"}
--- no_error_log
[error]
@ -117,8 +117,8 @@ passed
--- request
GET /hello
--- error_code: 404
--- response_body_like eval
qr/404 Not Found/
--- response_body
{"error_msg":"failed to match any routes"}
--- no_error_log
[error]

View File

@ -68,8 +68,8 @@ set_real_ip_from unix:;
--- request
GET /not_found
--- error_code: 404
--- response_body eval
qr/404 Not Found/
--- response_body
{"error_msg":"failed to match any routes"}
--- no_error_log
[error]
@ -85,8 +85,6 @@ GET /hello
--- more_headers
Host: not_found.com
--- error_code: 404
--- response_body eval
qr/404 Not Found/
--- no_error_log
[error]

View File

@ -64,8 +64,8 @@ passed
--- request
GET /not_found
--- error_code: 404
--- response_body eval
qr/404 Not Found/
--- response_body
{"error_msg":"failed to match any routes"}
--- no_error_log
[error]

View File

@ -64,8 +64,8 @@ passed
--- request
GET /hello?name=unknown
--- error_code: 404
--- response_body eval
qr/404 Not Found/
--- response_body
{"error_msg":"failed to match any routes"}
--- no_error_log
[error]

View File

@ -65,8 +65,8 @@ passed
--- request
GET /not_found
--- error_code: 404
--- response_body eval
qr/404 Not Found/
--- response_body
{"error_msg":"failed to match any routes"}
--- no_error_log
[error]
@ -76,8 +76,8 @@ qr/404 Not Found/
--- request
GET /hello
--- error_code: 404
--- response_body eval
qr/404 Not Found/
--- response_body
{"error_msg":"failed to match any routes"}
--- no_error_log
[error]
@ -89,8 +89,8 @@ GET /hello
--- more_headers
Host: not_found.com
--- error_code: 404
--- response_body eval
qr/404 Not Found/
--- response_body
{"error_msg":"failed to match any routes"}
--- no_error_log
[error]

View File

@ -64,8 +64,6 @@ passed
--- request
GET /not_found
--- error_code: 404
--- response_body eval
qr/404 Not Found/
--- no_error_log
[error]

View File

@ -64,8 +64,8 @@ passed
--- request
GET /not_found
--- error_code: 404
--- response_body eval
qr/404 Not Found/
--- response_body
{"error_msg":"failed to match any routes"}
--- no_error_log
[error]
@ -149,7 +149,7 @@ qr/404 Not Found/
--- request
GET /hel
--- error_code: 404
--- response_body eval
qr/404 Not Found/
--- response_body
{"error_msg":"failed to match any routes"}
--- no_error_log
[error]

View File

@ -90,8 +90,8 @@ passed
--- request
GET /not_found
--- error_code: 404
--- response_body eval
qr/404 Not Found/
--- response_body
{"error_msg":"failed to match any routes"}
--- no_error_log
[error]

View File

@ -102,8 +102,8 @@ passed
--- request
GET /not_found
--- error_code: 404
--- response_body eval
qr/404 Not Found/
--- response_body
{"error_msg":"failed to match any routes"}
--- no_error_log
[error]

View File

@ -89,8 +89,8 @@ passed
--- request
GET /not_found
--- error_code: 404
--- response_body eval
qr/404 Not Found/
--- response_body
{"error_msg":"failed to match any routes"}
--- no_error_log
[error]

View File

@ -63,8 +63,8 @@ passed
--- request
GET /not_found
--- error_code: 404
--- response_body eval
qr/404 Not Found/
--- response_body
{"error_msg":"failed to match any routes"}
--- no_error_log
[error]
@ -74,8 +74,8 @@ qr/404 Not Found/
--- request
GET /hello?k=not-hit
--- error_code: 404
--- response_body eval
qr/404 Not Found/
--- response_body
{"error_msg":"failed to match any routes"}
--- no_error_log
[error]
@ -129,8 +129,8 @@ passed
--- request
GET /hello
--- error_code: 404
--- response_body eval
qr/404 Not Found/
--- response_body
{"error_msg":"failed to match any routes"}
--- no_error_log
[error]
@ -142,8 +142,8 @@ Cookie: k=not-hit; kkk=vvv;
--- request
GET /hello
--- error_code: 404
--- response_body eval
qr/404 Not Found/
--- response_body
{"error_msg":"failed to match any routes"}
--- no_error_log
[error]
@ -199,8 +199,8 @@ passed
--- request
GET /hello
--- error_code: 404
--- response_body eval
qr/404 Not Found/
--- response_body
{"error_msg":"failed to match any routes"}
--- no_error_log
[error]
@ -212,8 +212,8 @@ k: not-hit
--- request
GET /hello
--- error_code: 404
--- response_body eval
qr/404 Not Found/
--- response_body
{"error_msg":"failed to match any routes"}
--- no_error_log
[error]
@ -269,8 +269,8 @@ passed
--- request
GET /hello
--- error_code: 404
--- response_body eval
qr/404 Not Found/
--- response_body
{"error_msg":"failed to match any routes"}
--- no_error_log
[error]
@ -282,8 +282,8 @@ k: header
--- request
GET /hello
--- error_code: 404
--- response_body eval
qr/404 Not Found/
--- response_body
{"error_msg":"failed to match any routes"}
--- no_error_log
[error]

View File

@ -61,8 +61,8 @@ passed
--- request
GET /not_found
--- error_code: 404
--- response_body eval
qr/404 Not Found/
--- response_body
{"error_msg":"failed to match any routes"}
--- no_error_log
[error]
@ -72,8 +72,8 @@ qr/404 Not Found/
--- request
GET /hello
--- error_code: 404
--- response_body eval
qr/404 Not Found/
--- response_body
{"error_msg":"failed to match any routes"}
--- no_error_log
[error]

View File

@ -80,8 +80,8 @@ passed
GET /not_found
--- yaml_config eval: $::yaml_config
--- error_code: 404
--- response_body eval
qr/404 Not Found/
--- response_body
{"error_msg":"failed to match any routes"}
--- no_error_log
[error]
@ -92,8 +92,8 @@ qr/404 Not Found/
GET /hello
--- yaml_config eval: $::yaml_config
--- error_code: 404
--- response_body eval
qr/404 Not Found/
--- response_body
{"error_msg":"failed to match any routes"}
--- no_error_log
[error]
@ -106,8 +106,8 @@ GET /hello
--- more_headers
Host: not_found.com
--- error_code: 404
--- response_body eval
qr/404 Not Found/
--- response_body
{"error_msg":"failed to match any routes"}
--- no_error_log
[error]
@ -176,8 +176,8 @@ passed
GET /hello
--- yaml_config eval: $::yaml_config
--- error_code: 404
--- response_body eval
qr/404 Not Found/
--- response_body
{"error_msg":"failed to match any routes"}
--- no_error_log
[error]
@ -235,8 +235,8 @@ passed
GET /hello2
--- yaml_config eval: $::yaml_config
--- error_code: 404
--- response_body eval
qr/404 Not Found/
--- response_body
{"error_msg":"failed to match any routes"}
--- no_error_log
[error]

View File

@ -80,8 +80,8 @@ passed
GET /not_found
--- yaml_config eval: $::yaml_config
--- error_code: 404
--- response_body eval
qr/404 Not Found/
--- response_body
{"error_msg":"failed to match any routes"}
--- no_error_log
[error]
@ -92,8 +92,6 @@ qr/404 Not Found/
GET /hello
--- yaml_config eval: $::yaml_config
--- error_code: 404
--- response_body eval
qr/404 Not Found/
--- no_error_log
[error]
@ -106,8 +104,6 @@ GET /hello
--- more_headers
Host: not_found.com
--- error_code: 404
--- response_body eval
qr/404 Not Found/
--- no_error_log
[error]
@ -180,8 +176,8 @@ passed
GET /not_found
--- yaml_config eval: $::yaml_config
--- error_code: 404
--- response_body eval
qr/404 Not Found/
--- response_body
{"error_msg":"failed to match any routes"}
--- no_error_log
[error]
@ -192,8 +188,6 @@ qr/404 Not Found/
GET /hello
--- yaml_config eval: $::yaml_config
--- error_code: 404
--- response_body eval
qr/404 Not Found/
--- no_error_log
[error]
@ -206,8 +200,6 @@ GET /hello
--- more_headers
Host: www.foo.com
--- error_code: 404
--- response_body eval
qr/404 Not Found/
--- no_error_log
[error]
@ -264,8 +256,8 @@ passed
--- request
GET /hello?name=unknown
--- error_code: 404
--- response_body eval
qr/404 Not Found/
--- response_body
{"error_msg":"failed to match any routes"}
--- no_error_log
[error]

View File

@ -146,8 +146,8 @@ passed
GET /not_found
--- yaml_config eval: $::yaml_config
--- error_code: 404
--- response_body eval
qr/404 Not Found/
--- response_body
{"error_msg":"failed to match any routes"}
--- no_error_log
[error]

View File

@ -80,8 +80,8 @@ passed
GET /not_found
--- yaml_config eval: $::yaml_config
--- error_code: 404
--- response_body eval
qr/404 Not Found/
--- response_body
{"error_msg":"failed to match any routes"}
--- no_error_log
[error]
@ -92,8 +92,8 @@ qr/404 Not Found/
GET /hello
--- yaml_config eval: $::yaml_config
--- error_code: 404
--- response_body eval
qr/404 Not Found/
--- response_body
{"error_msg":"failed to match any routes"}
--- no_error_log
[error]
@ -106,8 +106,8 @@ GET /hello
--- more_headers
Host: not_found.com
--- error_code: 404
--- response_body eval
qr/404 Not Found/
--- response_body
{"error_msg":"failed to match any routes"}
--- no_error_log
[error]
@ -166,8 +166,8 @@ passed
GET /hello
--- yaml_config eval: $::yaml_config
--- error_code: 404
--- response_body eval
qr/404 Not Found/
--- response_body
{"error_msg":"failed to match any routes"}
--- no_error_log
[error]
@ -226,8 +226,8 @@ passed
GET /hello2
--- yaml_config eval: $::yaml_config
--- error_code: 404
--- response_body eval
qr/404 Not Found/
--- response_body
{"error_msg":"failed to match any routes"}
--- no_error_log
[error]