diff --git a/spec/context_spec.cr b/spec/context_spec.cr index 1712756..3a0113c 100644 --- a/spec/context_spec.cr +++ b/spec/context_spec.cr @@ -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 diff --git a/src/kemal/context.cr b/src/kemal/context.cr index 5378b06..887320d 100644 --- a/src/kemal/context.cr +++ b/src/kemal/context.cr @@ -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