Sha256: c4ba27fe976673ff8db5e1042debb9ccd159fdafccd98024f084accb45fdf3e1

Contents?: true

Size: 815 Bytes

Versions: 19

Compression:

Stored size: 815 Bytes

Contents

# frozen_string_literal: true

module Salestation
  class Web < Module
    module InputValidators
      class AcceptHeader
        include Deterministic::Prelude

        def self.[](*allowed_headers)
          new(allowed_headers)
        end

        def initialize(allowed_headers)
          @allowed_headers = allowed_headers
        end

        def call(header_value)
          header_valid = @allowed_headers.empty? || @allowed_headers.include?(header_value)

          if header_valid
            Success(nil)
          else
            Failure(App::Errors::NotAcceptable.new(
              message: "Unsupported Accept Header '#{header_value}'",
              debug_message: "Available Accept Headers are #{@allowed_headers.join(', ')}"
            ))
          end
        end
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
salestation-4.2.0 lib/salestation/web/input_validators/accept_header.rb
salestation-4.1.0 lib/salestation/web/input_validators/accept_header.rb
salestation-4.0.3 lib/salestation/web/input_validators/accept_header.rb
salestation-4.0.2 lib/salestation/web/input_validators/accept_header.rb
salestation-4.0.1 lib/salestation/web/input_validators/accept_header.rb
salestation-4.0.0 lib/salestation/web/input_validators/accept_header.rb
salestation-3.9.0 lib/salestation/web/input_validators/accept_header.rb
salestation-3.8.1 lib/salestation/web/input_validators/accept_header.rb
salestation-3.8.0 lib/salestation/web/input_validators/accept_header.rb
salestation-3.7.0 lib/salestation/web/input_validators/accept_header.rb
salestation-3.6.0 lib/salestation/web/input_validators/accept_header.rb
salestation-3.5.1 lib/salestation/web/input_validators/accept_header.rb
salestation-3.5.0 lib/salestation/web/input_validators/accept_header.rb
salestation-3.4.0 lib/salestation/web/input_validators/accept_header.rb
salestation-3.3.0 lib/salestation/web/input_validators/accept_header.rb
salestation-3.2.2 lib/salestation/web/input_validators/accept_header.rb
salestation-3.2.1 lib/salestation/web/input_validators/accept_header.rb
salestation-3.2.0 lib/salestation/web/input_validators/accept_header.rb
salestation-3.1.0 lib/salestation/web/input_validators/accept_header.rb