route_defined? -> route_found?

This commit is contained in:
Serdar Dogruyol 2018-08-13 19:21:18 +03:00
parent 2b3ae85c34
commit e468e2e340
4 changed files with 5 additions and 5 deletions

View file

@ -34,7 +34,7 @@ class HTTP::Server
Kemal::RouteHandler::INSTANCE.lookup_route(@request.method.as(String), @request.path)
end
def route_defined?
def route_found?
route_lookup.found?
end
@ -42,7 +42,7 @@ class HTTP::Server
Kemal::WebSocketHandler::INSTANCE.lookup_ws_route(@request.path)
end
def ws_route_defined?
def ws_route_found?
ws_route_lookup.found?
end

View file

@ -12,7 +12,7 @@ module Kemal
# The call order of the filters is `before_all -> before_x -> X -> after_x -> after_all`.
def call(context : HTTP::Server::Context)
return call_next(context) unless context.route_defined?
return call_next(context) unless context.route_found?
call_block_for_path_type("ALL", context.request.path, :before, context)
call_block_for_path_type(context.request.method, context.request.path, :before, context)
if Kemal.config.error_handlers.has_key?(context.response.status_code)

View file

@ -29,7 +29,7 @@ module Kemal
# Processes the route if it's a match. Otherwise renders 404.
private def process_request(context)
raise Kemal::Exceptions::RouteNotFound.new(context) unless context.route_defined?
raise Kemal::Exceptions::RouteNotFound.new(context) unless context.route_found?
content = context.route.handler.call(context)
if !Kemal.config.error_handlers.empty? && Kemal.config.error_handlers.has_key?(context.response.status_code)

View file

@ -10,7 +10,7 @@ module Kemal
end
def call(context : HTTP::Server::Context)
return call_next(context) unless context.ws_route_defined? && websocket_upgrade_request?(context)
return call_next(context) unless context.ws_route_found? && websocket_upgrade_request?(context)
content = context.websocket.call(context)
context.response.print(content)
context