mirror of
https://gitea.invidious.io/iv-org/shard-kemal.git
synced 2024-08-15 00:53:36 +00:00
Added param parser
This commit is contained in:
parent
a8ad95aa67
commit
3cc50e0a7e
8 changed files with 72 additions and 52 deletions
16
spec/param_parser_spec.cr
Normal file
16
spec/param_parser_spec.cr
Normal file
|
@ -0,0 +1,16 @@
|
|||
require "./spec_helper"
|
||||
|
||||
describe "ParamParser" do
|
||||
it "parses params" do
|
||||
kemal = Kemal::Handler.new
|
||||
kemal.add_route "POST", "/" do |env|
|
||||
name = env.params["name"]
|
||||
age = env.params["age"]
|
||||
hasan = env.params["hasan"]
|
||||
"Hello #{name} #{hasan} #{age}"
|
||||
end
|
||||
request = HTTP::Request.new("POST", "/?hasan=cemal", body: "name=kemal&age=99")
|
||||
response = kemal.call(request)
|
||||
response.body.should eq("Hello kemal cemal 99")
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue