Class: Rack::PactBroker::InvalidUriProtection
- Inherits:
-
Object
- Object
- Rack::PactBroker::InvalidUriProtection
- Includes:
- PactBroker::Messages
- Defined in:
- lib/rack/pact_broker/invalid_uri_protection.rb
Constant Summary collapse
- CONSECUTIVE_SLASH =
/\/{2,}/
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ InvalidUriProtection
constructor
A new instance of InvalidUriProtection.
Methods included from PactBroker::Messages
#message, #pluralize, #validation_message, #validation_message_at_index
Constructor Details
#initialize(app) ⇒ InvalidUriProtection
Returns a new instance of InvalidUriProtection.
17 18 19 |
# File 'lib/rack/pact_broker/invalid_uri_protection.rb', line 17 def initialize app @app = app end |
Instance Method Details
#call(env) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rack/pact_broker/invalid_uri_protection.rb', line 21 def call env if (uri = valid_uri?(env)) if ( = validate(uri)) [422, headers, [body(env, , "Unprocessable", "invalid-request-parameter-value", 422)]] else app.call(env) end else [404, headers, [body(env, "Empty path component found", "Not Found", "not-found", 404)]] end end |