Class: Interpol::RequestBodyValidator
- Inherits:
-
Object
- Object
- Interpol::RequestBodyValidator
- Defined in:
- lib/interpol/request_body_validator.rb
Overview
Validates and parses a request body according to the endpoint schema definitions.
Defined Under Namespace
Classes: Handler
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, &block) ⇒ RequestBodyValidator
constructor
A new instance of RequestBodyValidator.
Constructor Details
#initialize(app, &block) ⇒ RequestBodyValidator
Returns a new instance of RequestBodyValidator.
8 9 10 11 |
# File 'lib/interpol/request_body_validator.rb', line 8 def initialize(app, &block) @config = Configuration.default.customized_duplicate(&block) @app = app end |
Instance Method Details
#call(env) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/interpol/request_body_validator.rb', line 13 def call(env) if @config.validate_request?(env) handler = Handler.new(env, @config) handler.validate do |error_response| return error_response end env['interpol.parsed_body'] = handler.parse end @app.call(env) end |