Parent

Methods

Class/Module Index [+]

Quicksearch

DispatchServlet

A custom dispatch servlet for use with WEBrick. It dispatches requests (using the Rails Dispatcher) to the appropriate controller/action. By default, it restricts WEBrick to a managing a single Rails request at a time, but you can change this behavior by setting ActionController::Base.allow_concurrency to true.

Public Class Methods

dispatch(options = {}) click to toggle source

Start the WEBrick server with the given options, mounting the DispatchServlet at /.

# File lib/webrick_server.rb, line 48
def self.dispatch(options = {})
  Socket.do_not_reverse_lookup = true # patch for OS X

  params = { :Port        => options[:port].to_i,
             :ServerType  => options[:server_type],
             :BindAddress => options[:ip] }
  params[:MimeTypes] = options[:mime_types] if options[:mime_types]

  server = WEBrick::HTTPServer.new(params)
  server.mount('/', DispatchServlet, options)

  trap("INT") { server.shutdown }
  server.start
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.