diff --git a/spec/kemal_handler_spec.cr b/spec/kemal_handler_spec.cr index ed423fa..f2fc3db 100644 --- a/spec/kemal_handler_spec.cr +++ b/spec/kemal_handler_spec.cr @@ -107,6 +107,6 @@ describe "Kemal::Handler" do kemal = Kemal::Handler.new request = HTTP::Request.new("GET", "/?message=world") response = kemal.call(request) - response.body.should eq("hello world") + response.status_code.should eq 404 end end diff --git a/src/kemal.cr b/src/kemal.cr index 94179c4..b46ea93 100644 --- a/src/kemal.cr +++ b/src/kemal.cr @@ -29,5 +29,13 @@ at_exit do exit } + # This route serves the built-in images for not_found and exceptions. + get "/__kemal__/:image" do |env| + image = env.params["image"] + file_path = File.expand_path("libs/kemal/images/#{image}", Dir.working_directory) + env.add_header "Content-Type", "application/octet-stream" + File.read(file_path) + end + server.listen end diff --git a/src/kemal/handler.cr b/src/kemal/handler.cr index 0e46bb4..26dbd9b 100644 --- a/src/kemal/handler.cr +++ b/src/kemal/handler.cr @@ -51,7 +51,7 @@ class Kemal::Handler < HTTP::Handler