Class: Pact::Server::Middleware

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Middleware

Returns a new instance of Middleware.



13
14
15
# File 'lib/pact/consumer/server.rb', line 13

def initialize(app)
  @app = app
end

Instance Attribute Details

#errorObject

Returns the value of attribute error.



11
12
13
# File 'lib/pact/consumer/server.rb', line 11

def error
  @error
end

Instance Method Details

#call(env) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/pact/consumer/server.rb', line 17

def call(env)
  if env["PATH_INFO"] == "/__identify__"
    [200, {}, [@app.object_id.to_s]]
  else
    begin
      @app.call(env)
    rescue StandardError => e
      @error = e unless @error
      raise e
    end
  end
end