Modiy HTTP::Params.[] to fetch all params (#328)

This commit is contained in:
Serdar Dogruyol 2017-03-13 16:52:42 +02:00 committed by GitHub
parent d0c034b911
commit 1177619da9
3 changed files with 88 additions and 98 deletions

8
src/kemal/ext/params.cr Normal file
View file

@ -0,0 +1,8 @@
module HTTP
struct Params
def [](name)
params = raw_params[name]
params.size == 1 ? params.first : params
end
end
end

View file

@ -1,5 +1,5 @@
class HTTP::Request
property override_method
property override_method : String?
property url_params : Hash(String, String)?
getter param_parser : Kemal::ParamParser?
@ -21,7 +21,7 @@ class HTTP::Request
@param_parser = Kemal::ParamParser.new(self)
params = @param_parser.not_nil!.body
if params.has_key?("_method") && HTTP::Request.override_method_valid?(params["_method"])
@override_method = params["_method"]
@override_method = params["_method"].as(String)
end
end
@override_method