class Odex::Req
Attributes
request[R]
response[R]
Public Class Methods
new(env)
click to toggle source
# File lib/odex/app.rb, line 27 def initialize(env) @request = Request.new(env) @request.params.merge!(env['odex.params']) @response = Response.new([], 200, {'Content-Type' => 'text/html'}) end
Public Instance Methods
apply_to(&handler)
click to toggle source
# File lib/odex/app.rb, line 52 def apply_to(&handler) data = instance_eval(&handler) data.respond_to?(:each) ? response.body = data : response.write(data) cookies.finish!(response) if @cookies response end
halt(status, headers={}, body='')
click to toggle source
# File lib/odex/app.rb, line 41 def halt(status, headers={}, body='') @response = Response.new(body, status, headers) cookies.finish!(response) if @cookies throw(:halt, response) end
status(code)
click to toggle source
# File lib/odex/app.rb, line 37 def status(code) response.status = code end
system_redirect_to(uri, status=302)
click to toggle source
# File lib/odex/app.rb, line 47 def system_redirect_to(uri, status=302) halt(status, {'Location' => uri}) end
Also aliased as: redirect