Class: FaradayCage::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/faraday_cage/server.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app = FaradayCage.app) ⇒ Server

Returns a new instance of Server.



12
13
14
15
16
17
18
19
20
# File 'lib/faraday_cage/server.rb', line 12

def initialize(app = FaradayCage.app)
  if app
    @app = app
  else
    raise Error, 'No Rack app configured. Please see documentation for details.'
  end

  @middleware = RackMiddleware.new(app)
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



10
11
12
# File 'lib/faraday_cage/server.rb', line 10

def app
  @app
end

Instance Method Details

#connectionObject



22
23
24
25
26
27
28
29
30
# File 'lib/faraday_cage/server.rb', line 22

def connection
  @connection ||= Faraday.new(FaradayCage.default_host) do |conn|
    if FaradayCage.middleware.respond_to?(:call)
      FaradayCage.middleware.call(conn)
    end

    conn.adapter :rack, app
  end
end