Class: Rack::PactBroker::InvalidUriProtection

Inherits:
Object
  • Object
show all
Includes:
PactBroker::Messages
Defined in:
lib/rack/pact_broker/invalid_uri_protection.rb

Instance Method Summary collapse

Methods included from PactBroker::Messages

#message, #pluralize, #potential_duplicate_pacticipant_message, #validation_message

Constructor Details

#initialize(app) ⇒ InvalidUriProtection

Returns a new instance of InvalidUriProtection.



15
16
17
# File 'lib/rack/pact_broker/invalid_uri_protection.rb', line 15

def initialize app
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/rack/pact_broker/invalid_uri_protection.rb', line 19

def call env
  if (uri = valid_uri?(env))
    if (error_message = validate(uri))
      [422, {"Content-Type" => "text/plain"}, [error_message]]
    else
      app.call(env)
    end
  else
    [404, {}, []]
  end
end