Added headers to context

This commit is contained in:
Serdar Dogruyol 2015-10-30 17:06:25 +02:00
parent 5892d900ff
commit ffdaecace4
2 changed files with 17 additions and 0 deletions

View file

@ -20,4 +20,17 @@ describe "Context" do
response = kemal.call(request)
response.headers["Content-Type"].should eq("application/json")
end
it "parses headers" do
kemal = Kemal::Handler.new
kemal.add_route "GET", "/" do |env|
name = env.headers["name"]
"Hello #{name}"
end
headers = HTTP::Headers.new
headers["Name"] = "kemal"
request = HTTP::Request.new("GET", "/", headers)
response = kemal.call(request)
response.body.should eq "Hello kemal"
end
end

View file

@ -9,6 +9,10 @@ class Kemal::Context
@content_type = "text/html"
end
def headers
request.headers
end
def set_content_type(content_type)
@content_type = content_type
end