Class: Thick::Loader
- Inherits:
-
Object
- Object
- Thick::Loader
- Includes:
- Java::ServerRubyInterface
- Defined in:
- lib/thick/loader.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(options) ⇒ Loader
constructor
A new instance of Loader.
Constructor Details
#initialize(options) ⇒ Loader
7 8 9 10 11 |
# File 'lib/thick/loader.rb', line 7 def initialize() = ENV['RACK_ENV'] ||= ENV['RAILS_ENV'] ||= [:environment] @application = Rack::Builder.parse_file([:file])[0] end |
Instance Method Details
#call(env) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/thick/loader.rb', line 13 def call(env) env['rack.input'] = env['rack.input'].to_io env['rack.errors'] = env['rack.errors'].to_io status, headers, body = @application.call(env) response = env['thick.response'] response.setStatus(status) headers.each_pair do |name, value| response.setHeader(name, value) end if body.respond_to?(:to_path) response.send_file(body.to_path) else body.each { |chunk| response.writeContent(chunk.to_s) } response.send env['thick.async'].call(response) if response.chunked? end rescue => e puts e. puts e.backtrace end |