Remove redundant intermediate var from process_route

This commit is contained in:
Serdar Dogruyol 2017-09-04 23:46:53 +03:00
parent b8e3298925
commit 422313425c
2 changed files with 5 additions and 2 deletions

View File

@ -32,6 +32,10 @@ class HTTP::Server
@response.status_code = status_code
end
def route
route_lookup.payload.as(Route)
end
def route_lookup
Kemal::RouteHandler::INSTANCE.lookup_route(@request.override_method.as(String), @request.path)
end

View File

@ -42,8 +42,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?
route = context.route_lookup.payload.as(Route)
content = route.handler.call(context)
content = context.route.handler.call(context)
ensure
if Kemal.config.error_handlers.has_key?(context.response.status_code)
raise Kemal::Exceptions::CustomException.new(context)