add GPLv3 option to the license
[unicorn.git] / lib / unicorn / app / old_rails.rb
blobad1ca8e8968749ff2ba80081abc5d8d21924ad4e
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 1.8 or
8 # the GPLv3
9 # Additional work donated by contributors.  See CONTRIBUTORS for more info.
10 require 'unicorn/cgi_wrapper'
11 require 'dispatcher'
13 module Unicorn; module App; end; end
15 # Implements a handler that can run Rails.
16 class Unicorn::App::OldRails
18   autoload :Static, "unicorn/app/old_rails/static"
20   def call(env)
21     cgi = Unicorn::CGIWrapper.new(env)
22     begin
23       Dispatcher.dispatch(cgi,
24           ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS,
25           cgi.body)
26     rescue => e
27       err = env['rack.errors']
28       err.write("#{e} #{e.message}\n")
29       e.backtrace.each { |line| err.write("#{line}\n") }
30     end
31     cgi.out  # finalize the response
32     cgi.rack_response
33   end
35 end