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
Returns a new instance of Loader.
7 8 9 10 11 |
# File 'lib/thick/loader.rb', line 7 def initialize() = ENV['RACK_ENV'] ||= ENV['RAILS_ENV'] ||= [:environment] @application = [:application] ||= Rack::Builder.parse_file(File.([:file], [:directory]))[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 38 39 40 41 42 43 44 |
# File 'lib/thick/loader.rb', line 13 def call(env) env['rack.input'] = Buffer.new(env['rack.input']) env['rack.errors'] = env['rack.errors'].to_io status, headers, body = @application.call(env) return if env['thick.response_bypass'] response = env['thick.response'] response.setStatus(status) hijack = headers.delete('rack.hijack') 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 # Rack Hijack async response hijack.call(env['rack.hijakck_io']) if hijack # Thick native async response env['thick.async'].call(response) if response.chunked? end rescue => e puts e. puts e.backtrace end |