1 require File.dirname(__FILE__) + '/context/renderer'
10 include Sinatra::Renderer
12 def initialize(request) #:nodoc:
17 # Sets or returns the status
18 def status(value = nil)
19 @status = value if value
23 # Sets or returns the body
32 def body(value = nil, &block)
33 @body = value if value
34 @body = block.call if block
38 # Renders an exception to +body+ and sets status to 500
39 def error(value = nil)
43 erb :error, :views_directory => SINATRA_ROOT + '/files/'
48 # Sets or returns response headers
51 # header 'Content-Type' => 'text/html'
52 # header 'Foo' => 'Bar'
54 # headers 'Content-Type' => 'text/html',
57 # Whatever blows your hair back
58 def headers(value = nil)
59 @headers.merge!(value) if value
62 alias :header :headers
64 # Returns a Hash of params. Keys are symbolized
66 @params ||= @request.params.symbolize_keys
71 logger.info "Redirecting to: #{path}"
73 header 'Location' => path
76 def log_event #:nodoc:
77 logger.info "#{request.request_method} #{request.path_info} | Status: #{status} | Params: #{params.inspect}"
78 logger.exception(error) if error