diff options
author | Eric Wong <normalperson@yhbt.net> | 2009-03-23 02:03:31 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2009-03-23 14:42:41 -0700 |
commit | 0b095ea72fb849682a1185a626eef247b5afc1cd (patch) | |
tree | b8f74a3160b3842bbebcf2fe3c5c917ec088e8eb /lib/unicorn/app/old_rails.rb | |
parent | 451a1022e16ec6307328125a41244a837c6edcdf (diff) | |
download | unicorn-0b095ea72fb849682a1185a626eef247b5afc1cd.tar.gz |
This resurrects old code from Mongrel to wrap the Rails Dispatcher for older versions of Rails. It seems that Rails >= 2.2.0 support Rack, but only >=2.3 requires it. I'd like to support Rails 1.2.x for a while, too.
Diffstat (limited to 'lib/unicorn/app/old_rails.rb')
-rw-r--r-- | lib/unicorn/app/old_rails.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/unicorn/app/old_rails.rb b/lib/unicorn/app/old_rails.rb new file mode 100644 index 0000000..bb9577a --- /dev/null +++ b/lib/unicorn/app/old_rails.rb @@ -0,0 +1,23 @@ +# This code is based on the original Rails handler in Mongrel +# Copyright (c) 2005 Zed A. Shaw +# Copyright (c) 2009 Eric Wong +# You can redistribute it and/or modify it under the same terms as Ruby. +# Additional work donated by contributors. See CONTRIBUTORS for more info. +require 'unicorn/cgi_wrapper' +require 'dispatcher' + +module Unicorn; module App; end; end + +# Implements a handler that can run Rails. +class Unicorn::App::OldRails + + def call(env) + cgi = Unicorn::CGIWrapper.new(env) + Dispatcher.dispatch(cgi, + ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS, + cgi.body) + cgi.out # finalize the response + cgi.rack_response + end + +end |