Remove Context#app to reduce GC load (experimental)

This commit is contained in:
Johannes Müller 2017-10-18 17:53:44 +02:00 committed by sdogruyol
parent 72bcac6dd5
commit 5917af3f14
5 changed files with 8 additions and 15 deletions

View file

@ -22,14 +22,14 @@ describe "ParamParser" do
end
it "parses url params" do
kemal = Kemal.application.route_handler
kemal.add_route "POST", "/hello/:hasan" do |env|
route_handler = Kemal.application.route_handler
route_handler.add_route "POST", "/hello/:hasan" do |env|
"hello #{env.params.url["hasan"]}"
end
request = HTTP::Request.new("POST", "/hello/cemal")
# Radix tree MUST be run to parse url params.
context = create_request_and_return_io_and_context(kemal, request)[1]
url_params = Kemal::ParamParser.new(request, context.route_lookup.params).url
io_with_context = create_request_and_return_io(route_handler, request)
url_params = Kemal::ParamParser.new(request).url
url_params["hasan"].should eq "cemal"
end