Class: Miron::Handler::Thin

Inherits:
Thin::Server
  • Object
show all
Defined in:
lib/miron/handlers/thin.rb

Defined Under Namespace

Classes: Proxy

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mironfile, *args) ⇒ Thin


10
11
12
13
# File 'lib/miron/handlers/thin.rb', line 10

def initialize(mironfile, *args)
  @mironfile = mironfile
  super
end

Class Method Details

.run(mironfile, options = {}) ⇒ Object


6
7
8
# File 'lib/miron/handlers/thin.rb', line 6

def self.run(mironfile, options = {})
  Thin::Proxy.new(mironfile, options)
end

Instance Method Details

#call(env) ⇒ Object


15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/miron/handlers/thin.rb', line 15

def call(env)
  # Get response
  miron_request = env
  miron_response = Miron::RequestFetcher.new(miron_request, @mironfile).fetch_response
  # Process response
  response_http_status = miron_response.http_status
  # Add cookies to headers
  miron_response.cookies.each do |k, v|
    miron_response.headers['Set-Cookie'] = "#{k}=#{v}"
  end
  response_body = [miron_response.body]
  # Write back to Unicorn
  [response_http_status, miron_response.headers, response_body]
end

#startObject


30
31
32
33
# File 'lib/miron/handlers/thin.rb', line 30

def start
  @app = self
  super
end