Sha256: df2bf0b54c7db61e95ff0b43c83c2b33acb08f0217508be3356a6fa73be3f440
Contents?: true
Size: 1.34 KB
Versions: 1
Compression:
Stored size: 1.34 KB
Contents
module Praxis module RequestStages class ValidateParamsAndHeaders < RequestStage attr_reader :parent def initialize(name, context, parent:) super @parent = parent end def path @_path ||= ( @parent.path + [name] ) end def execute begin request.load_headers(CONTEXT_FOR[:headers]) rescue => e message = "Error loading headers." return validation_handler.handle!( exception: e, summary: message, request: request, stage: name ) end begin request.load_params(CONTEXT_FOR[:params]) rescue Attributor::AttributorException => e message = "Error loading params." return validation_handler.handle!( exception: e, summary: message, request: request, stage: name ) end errors = request.validate_headers(CONTEXT_FOR[:headers]) errors += request.validate_params(CONTEXT_FOR[:params]) if errors.any? message = "Error validating request data." return validation_handler.handle!( summary: message, errors: errors, request: request, stage: name ) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
praxis-2.0.pre.18 | lib/praxis/request_stages/validate_params_and_headers.rb |