kemal/src/kemal/context.cr

30 lines
612 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 20:01:18 +00:00
def response_headers
@response.headers
end
2015-10-30 20:34:44 +00:00
def add_header(name, value)
2015-10-30 20:01:18 +00:00
@response.headers.add name, value
end
def content_type
@response.content_type
2015-10-30 15:06:25 +00:00
end
2015-10-30 20:34:44 +00:00
delegate headers, @request
2015-10-30 20:01:18 +00:00
delegate status_code, @response
2015-10-30 20:34:44 +00:00
delegate :"status_code=", @response
delegate :"content_type=", @response
end