Fixes for Crystal 0.19

This commit is contained in:
Amit Saha 2016-09-06 13:21:24 +10:00
parent 8c0d4268b9
commit f2659b06fd
3 changed files with 16 additions and 6 deletions

View file

@ -10,7 +10,7 @@ describe "SpecKemalApp" do
it "handles post" do
json_body = {"name": "Serdar", "age": 27, "skills": ["crystal, kemal"]}
post("/user", headers: HTTP::Headers{"Content-Type": "application/json"}, body: json_body.to_json)
post("/user", headers: HTTP::Headers{"Content-Type" => "application/json"}, body: json_body.to_json)
response.body.should eq(json_body.to_json)
end
end

View file

@ -10,7 +10,7 @@ end
post "/user" do |env|
env.response.content_type = "application/json"
name = env.params.json["name"]
age = env.params.json["age"] as Int
skills = env.params.json["skills"] as Array
age = env.params.json["age"]
skills = env.params.json["skills"]
{"name": name, "age": age, "skills": skills}.to_json
end