Module: RazorRisk::Sinatra::Helpers::ValidateContentTypeHelper

Includes:
Xqsr3::Quality::ParameterChecking
Defined in:
lib/razor_risk/sinatra/helpers/validate_content_type_helper.rb

Overview

########################################################################## ValidateContentTypeHelper

Instance Method Summary collapse

Instance Method Details

#validate_content_type(*args, **options) ⇒ Object



42
43
44
45
46
47
48
49
50
51
# File 'lib/razor_risk/sinatra/helpers/validate_content_type_helper.rb', line 42

def validate_content_type *args, **options

    rq  =   args.shift
    ar  =   args.shift

    halt 415, %Q<invalid content-type '('#{rq.content_type}')', must be one of #{ar.map { |a| "'#{a}'" }.join(', ')}> unless ar.any? do |ct|

        rq.content_type.start_with? ct
    end
end