app | The app that Mongrel should handle. |
:api: plugin
# File lib/merb-core/rack/handler/mongrel.rb, line 53 53: def initialize(app) 54: @app = app 55: end
Runs the server and yields it to a block.
app | The app that Mongrel should handle. |
options | Options to pass to Mongrel (see below). |
server | The server to run. |
:Host | The hostname on which the app should run. Defaults to “0.0.0.0“ |
:Port | The port for the app. Defaults to 8080. |
:api: plugin
# File lib/merb-core/rack/handler/mongrel.rb, line 36 36: def self.run(app, options={}) 37: @server = ::Mongrel::HttpServer.new(options[:Host] || '0.0.0.0', 38: options[:Port] || 8080) 39: @server.register('/', ::Merb::Rack::Handler::Mongrel.new(app)) 40: yield @server if block_given? 41: @server.run.join 42: end
request | The HTTP request to handle. |
response | The response object to write response to. |
:api: plugin
# File lib/merb-core/rack/handler/mongrel.rb, line 62 62: def process(request, response) 63: env = {}.replace(request.params) 64: env.delete Merb::Const::HTTP_CONTENT_TYPE 65: env.delete Merb::Const::HTTP_CONTENT_LENGTH 66: 67: env[Merb::Const::SCRIPT_NAME] = Merb::Const::EMPTY_STRING if env[Merb::Const::SCRIPT_NAME] == Merb::Const::SLASH 68: 69: env.update({"rack.version" => [0,1], 70: "rack.input" => request.body || StringIO.new(""), 71: "rack.errors" => STDERR, 72: 73: "rack.multithread" => true, 74: "rack.multiprocess" => false, # ??? 75: "rack.run_once" => false, 76: 77: "rack.url_scheme" => "http" 78: }) 79: env[Merb::Const::QUERY_STRING] ||= "" 80: env.delete Merb::Const::PATH_INFO if env[Merb::Const::PATH_INFO] == Merb::Const::EMPTY_STRING 81: 82: status, headers, body = @app.call(env) 83: 84: begin 85: response.status = status.to_i 86: response.send_status(nil) 87: 88: headers.each { |k, vs| 89: vs.split(Merb::Const::NEWLINE).each { |v| 90: response.header[k] = v 91: } 92: } 93: response.send_header 94: 95: body.each { |part| 96: response.write(part) 97: response.socket.flush 98: } 99: response.done = true 100: ensure 101: body.close if body.respond_to? :close 102: end 103: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.