mirror of
https://gitea.invidious.io/iv-org/shard-kemal.git
synced 2024-08-15 00:53:36 +00:00
Added JSON body parsing
This commit is contained in:
parent
5e1460bd31
commit
3687897005
3 changed files with 93 additions and 1 deletions
|
@ -30,6 +30,20 @@ describe "ParamParser" do
|
|||
params.should eq({"hasan" => "cemal", "name" => "serdar", "age" => "99"})
|
||||
end
|
||||
|
||||
it "parses request body" do
|
||||
route = Route.new "POST", "/" { }
|
||||
|
||||
request = HTTP::Request.new(
|
||||
"POST",
|
||||
"/",
|
||||
body: "{\"name\": \"Serdar\"}",
|
||||
headers: HTTP::Headers{"Content-Type": "application/json"},
|
||||
)
|
||||
|
||||
params = Kemal::ParamParser.new(route, request).parse
|
||||
params.should eq({"name": "Serdar"})
|
||||
end
|
||||
|
||||
context "when content type is incorrect" do
|
||||
it "does not parse request body" do
|
||||
route = Route.new "POST", "/" do |env|
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue