decoupled-urlparams-from-routehandler

This commit is contained in:
Joris Moriau 2016-02-19 11:34:45 +01:00
parent 43d34886c4
commit 8f6b00ba55
3 changed files with 2 additions and 2 deletions

View file

@ -3,6 +3,7 @@
class HTTP::Server class HTTP::Server
class Context class Context
def params def params
@request.url_params = route_lookup.params
@params ||= Kemal::ParamParser.new(@request).parse @params ||= Kemal::ParamParser.new(@request).parse
end end

View file

@ -18,10 +18,10 @@ class Kemal::ParamParser
end end
def parse_request def parse_request
parse_url_params
parse_query parse_query
parse_body parse_body
parse_json parse_json
parse_url_params
@params @params
end end

View file

@ -33,7 +33,6 @@ class Kemal::RouteHandler < HTTP::Handler
def process_request(context) def process_request(context)
raise Kemal::Exceptions::RouteNotFound.new(context) unless context.route_defined? raise Kemal::Exceptions::RouteNotFound.new(context) unless context.route_defined?
route = context.route_lookup.payload as Route route = context.route_lookup.payload as Route
context.request.url_params = context.route_lookup.params
context.response.print(route.handler.call(context).to_s) context.response.print(route.handler.call(context).to_s)
context context
end end