kemal/src/kemal/context.cr

35 lines
634 B
Crystal
Raw Normal View History

# Context is the environment which holds request/response specific
# information such as params, content_type e.g
2015-10-23 18:33:26 +00:00
class Kemal::Context
getter request
2015-10-30 20:01:18 +00:00
getter response
2015-10-28 16:09:45 +00:00
getter params
2015-10-28 18:52:34 +00:00
getter content_type
2015-10-28 16:09:45 +00:00
def initialize(@request, @params)
2015-10-30 20:01:18 +00:00
@response = Kemal::Response.new
end
2015-10-30 15:06:25 +00:00
def headers
2015-10-30 20:01:18 +00:00
@request.headers
end
def response_headers
@response.headers
end
def set_header(name, value)
@response.headers.add name, value
end
def content_type
@response.content_type
2015-10-30 15:06:25 +00:00
end
2015-10-28 18:52:34 +00:00
def set_content_type(content_type)
2015-10-30 20:01:18 +00:00
@response.content_type = content_type
end
2015-10-30 20:01:18 +00:00
delegate status_code, @response
end