Class: Thin::RailsHandler
Overview
Forwards incoming request to Rails dispatcher.
Instance Method Summary collapse
-
#initialize(pwd, env = 'development') ⇒ RailsHandler
constructor
A new instance of RailsHandler.
- #process(request, response) ⇒ Object
- #start ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(pwd, env = 'development') ⇒ RailsHandler
Returns a new instance of RailsHandler.
4 5 6 7 |
# File 'lib/thin/rails.rb', line 4 def initialize(pwd, env='development') @env = env @pwd = pwd end |
Instance Method Details
#process(request, response) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/thin/rails.rb', line 16 def process(request, response) # Rails doesn't serve static files # TODO handle Rails page caching return false if File.file?(File.join(@pwd, 'public', request.path)) cgi = CGIWrapper.new(request, response) Dispatcher.dispatch(cgi, ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS, response.body) # This finalizes the output using the proper HttpResponse way cgi.out("text/html", true) {""} end |
#start ⇒ Object
9 10 11 12 13 14 |
# File 'lib/thin/rails.rb', line 9 def start ENV['RAILS_ENV'] = @env require "#{@pwd}/config/environment" require 'dispatcher' end |
#to_s ⇒ Object
29 30 31 |
# File 'lib/thin/rails.rb', line 29 def to_s "Rails on #{@pwd} (env=#{@env})" end |