documentation cleanup/reduction
[unicorn.git] / lib / unicorn / app / old_rails.rb
blob5f04ce7b44aac2c5b1a2f8d9cacff45c6c812dac
1 # -*- encoding: binary -*-
3 # :enddoc:
4 # This code is based on the original Rails handler in Mongrel
5 # Copyright (c) 2005 Zed A. Shaw
6 # Copyright (c) 2009 Eric Wong
7 # You can redistribute it and/or modify it under the same terms as Ruby.
8 # Additional work donated by contributors.  See CONTRIBUTORS for more info.
9 require 'unicorn/cgi_wrapper'
10 require 'dispatcher'
12 module Unicorn; module App; end; end
14 # Implements a handler that can run Rails.
15 class Unicorn::App::OldRails
17   autoload :Static, "unicorn/app/old_rails/static"
19   def call(env)
20     cgi = Unicorn::CGIWrapper.new(env)
21     begin
22       Dispatcher.dispatch(cgi,
23           ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS,
24           cgi.body)
25     rescue => e
26       err = env['rack.errors']
27       err.write("#{e} #{e.message}\n")
28       e.backtrace.each { |line| err.write("#{line}\n") }
29     end
30     cgi.out  # finalize the response
31     cgi.rack_response
32   end
34 end