2016-07-17 15:11:26 +00:00
|
|
|
module Kemal
|
2017-10-06 11:53:53 +00:00
|
|
|
# Initializes the context with default values, such as
|
|
|
|
# *Content-Type* or *X-Powered-By* headers.
|
2016-12-24 11:22:44 +00:00
|
|
|
class InitHandler
|
|
|
|
include HTTP::Handler
|
2018-03-17 14:58:19 +00:00
|
|
|
|
2016-07-17 15:11:26 +00:00
|
|
|
INSTANCE = new
|
|
|
|
|
2017-08-25 13:41:02 +00:00
|
|
|
def call(context : HTTP::Server::Context)
|
2018-05-09 07:19:59 +00:00
|
|
|
context.response.headers.add "X-Powered-By", "Kemal" if Kemal.config.powered_by_header
|
2016-07-17 17:23:45 +00:00
|
|
|
context.response.content_type = "text/html" unless context.response.headers.has_key?("Content-Type")
|
2016-07-17 17:42:00 +00:00
|
|
|
call_next context
|
2016-07-17 15:11:26 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|