mirror of
https://gitea.invidious.io/iv-org/shard-kemal.git
synced 2024-08-15 00:53:36 +00:00
Don't use JSON::Type, use JSON::Any instead (#435)
This commit is contained in:
parent
50f82f5187
commit
db00ecba1d
3 changed files with 3 additions and 4 deletions
|
@ -174,7 +174,7 @@ describe "ParamParser" do
|
|||
body_params.to_s.should eq("")
|
||||
|
||||
json_params = Kemal::ParamParser.new(request).json
|
||||
json_params.should eq({} of String => Nil | String | Int64 | Float64 | Bool | Hash(String, JSON::Type) | Array(JSON::Type))
|
||||
json_params.should eq({} of String => Nil | String | Int64 | Float64 | Bool | Hash(String, JSON::Any) | Array(JSON::Any))
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -85,7 +85,6 @@ describe "Kemal::RouteHandler" do
|
|||
post "/" do |env|
|
||||
skills = env.params.json["skills"].as(Array)
|
||||
skills_from_languages = skills.map do |skill|
|
||||
skill = skill.as(Hash)
|
||||
skill["language"]
|
||||
end
|
||||
"Skills #{skills_from_languages.each.join(',')}"
|
||||
|
|
|
@ -8,7 +8,7 @@ module Kemal
|
|||
MULTIPART_FORM = "multipart/form-data"
|
||||
PARTS = %w(url query body json)
|
||||
# :nodoc:
|
||||
alias AllParamTypes = Nil | String | Int64 | Float64 | Bool | Hash(String, JSON::Type) | Array(JSON::Type)
|
||||
alias AllParamTypes = Nil | String | Int64 | Float64 | Bool | Hash(String, JSON::Any) | Array(JSON::Any)
|
||||
getter files
|
||||
|
||||
def initialize(@request : HTTP::Request)
|
||||
|
@ -89,7 +89,7 @@ module Kemal
|
|||
case json = JSON.parse(body).raw
|
||||
when Hash
|
||||
json.each do |key, value|
|
||||
@json[key] = value.as(AllParamTypes)
|
||||
@json[key] = value.raw
|
||||
end
|
||||
when Array
|
||||
@json["_json"] = json
|
||||
|
|
Loading…
Reference in a new issue