Add next handler to init_handler_spec

This commit is contained in:
Sdogruyol 2016-07-17 20:42:00 +03:00
parent d1c788f065
commit b00bc7a202
2 changed files with 2 additions and 1 deletions

View file

@ -6,6 +6,7 @@ describe "Kemal::InitHandler" do
io = MemoryIO.new io = MemoryIO.new
response = HTTP::Server::Response.new(io) response = HTTP::Server::Response.new(io)
context = HTTP::Server::Context.new(request, response) context = HTTP::Server::Context.new(request, response)
Kemal::InitHandler::INSTANCE.next = ->(context : HTTP::Server::Context) {}
Kemal::InitHandler::INSTANCE.call(context) Kemal::InitHandler::INSTANCE.call(context)
context.response.headers["Content-Type"].should eq "text/html" context.response.headers["Content-Type"].should eq "text/html"
end end

View file

@ -6,8 +6,8 @@ module Kemal
def call(context) def call(context)
context.response.headers.add "X-Powered-By", "Kemal" context.response.headers.add "X-Powered-By", "Kemal"
call_next context
context.response.content_type = "text/html" unless context.response.headers.has_key?("Content-Type") context.response.content_type = "text/html" unless context.response.headers.has_key?("Content-Type")
call_next context
end end
end end
end end