0
+ # A Dispatcher in Waves is the interface between the outside world and the Waves application code.
0
+ # Dispatchers that inherit from Waves::Dispatchers::Base are "Rack applications", to use the
0
+ # terminology of the Rack specification.
0
+ # Rack turns an incoming HTTP request into a environment hash and passes it as an argument to
0
+ # the Dispatcher's +call+ method. The dispatcher must return an array containing the status code,
0
+ # response headers, and response body. Waves::Dispatchers::Base provides a basic structure so that
0
+ # subclassed dispatchers need only implement the +safe+ method, which operates on a Waves::Request
0
+ # and returns a Waves::Response. The +call+ method implemented by the Base dispatcher formats the
0
+ # return value required by the Rack specification.
0
+ # You can write your own dispatcher and use it in the Rack::Builder block in your configuration
0
+ # files. By default, the configurations use the Default dispatcher:
0
+ # use Rack::ShowExceptions
0
+ # run Waves::Dispatchers::Default.new
0
- # Waves::Dispatchers::Default matches requests against an application's mappings to
0
- # determine what main action to take, as well as what before, after, always, and exception-handling
0
- # The default dispatcher also attempts to set the content type based on the
0
- # file extension used in the request URL. It does this using the class defined in
0
- # the current configuration's +mime_types+ attribute, which defaults to Mongrel's
0
- # You can write your own dispatcher and use it in your application's configuration
0
- # file. By default, they use the default dispatcher, like this:
0
- # use Rack::ShowExceptions
0
- # run Waves::Dispatchers::Default.new
0
+ # Waves::Dispatchers::Default processes a Waves::Request and returns a Waves::Response as follows:
0
+ # 1. reload any reloadable constants if Waves.debug? is true
0
+ # 1. determine the content type using the mime-type indicated by the request URL's file extension
0
+ # 1. evaluate all :before mappings that match the request
0
+ # 1. evaluate the first :action mapping that matches the request. If nothing matches, raise a NotFoundError
0
+ # 1. evalute all :after mappings that match the request
0
+ # 1. if any exceptions were raised, evaluate the first
0
+ # exception handler that matches the request. If no handlers match the request, re-raise the exception.
0
+ # 1. evaluate every :always mapping that matches the request. Log any exceptions and continues.
0
- # Takes a Waves::Request and returns a Waves::Response, reloading the reloadable application constants
0
- # if Waves.debug? is true. +safe+ processes the request by searching the application mappings for an action,
0
- # as well as any matching :before and :after filters. If an exception is raised during the processing,
0
- # +safe+ looks for an exception handler in the mappings. After processing the filters, action, and any
0
- # exception handlers, the method evaluates any :always filters that matched the request.
0
+ # Takes a Waves::Request and returns a Waves::Response
0
response = request.response
Comments
No one has commented yet.