unicorn.git  about / heads / tags
Rack HTTP server for Unix and fast clients
blob 4b74666efb7341f152606c3244a54a3e8ed12bfd 847 bytes (raw)
$ git show v0.5.2:lib/unicorn/app/old_rails.rb	# shows this blob on the CLI

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
 
# 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)
    begin
      Dispatcher.dispatch(cgi,
          ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS,
          cgi.body)
    rescue Object => e
      err = env['rack.errors']
      out.write("#{e} #{e.message}\n")
      e.backtrace.each { |line| out.write("#{line}\n") }
    end
    cgi.out  # finalize the response
    cgi.rack_response
  end

end

git clone https://yhbt.net/unicorn.git