Class: Miron::Handler::Puma

Inherits:
Object
  • Object
show all
Defined in:
lib/miron/handlers/puma.rb

Defined Under Namespace

Classes: Proxy

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mironfile) ⇒ Puma

Returns a new instance of Puma


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

def initialize(mironfile)
  @mironfile = mironfile
end

Class Method Details

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


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

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

Instance Method Details

#call(env) ⇒ Object


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

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]
  [response_http_status, miron_response.headers, response_body]
end