class Sparrow::Configuration

Middleware configuration store see {github.com/GateprotectGmbH/sparrow#configuration}

Attributes

allowed_accepts[RW]
allowed_content_types[RW]
camelize_ignore_uppercase_keys[RW]
camelize_strategy[RW]
default_json_request_key_transformation_strategy[RW]
default_json_response_key_transformation_strategy[RW]
enable_logging[RW]
excluded_routes[RW]
ignored_response_codes[RW]
json_request_format_header[RW]
json_response_format_header[RW]

Public Class Methods

new() click to toggle source

Initializes a new Configuration with default parameters

# File lib/sparrow/configuration.rb, line 19
def initialize
  @enable_logging                                    = false
  @json_request_format_header                        = 'request-json-format'
  @json_response_format_header                       = 'response-json-format'
  @excluded_routes                                   = []
  @default_json_request_key_transformation_strategy  = :underscore
  @default_json_response_key_transformation_strategy = :camelize
  @camelize_ignore_uppercase_keys                    = true
  @allowed_content_types                             = %w[
    application/json
    application/x-www-form-urlencoded
    text/x-json
  ]

  @allowed_accepts        = @allowed_content_types + [nil]
  @ignored_response_codes = [404] + (500..511).to_a
  @camelize_strategy      = :lower
end

Public Instance Methods

active_support_legacy_version() click to toggle source
# File lib/sparrow/configuration.rb, line 38
def active_support_legacy_version
  /3\.\d+\.\d+/
end
default_json_key_transformation_strategy(type) click to toggle source

the default json_key_transformation_strategy option for the given http message type @param type [String] http message type. Must be either 'request' or

'response'

@return [String] the configuration option value

# File lib/sparrow/configuration.rb, line 57
def default_json_key_transformation_strategy(type)
  public_send("default_json_#{type}_key_transformation_strategy")
end
json_format_header(type) click to toggle source

@param type [String] the http message type.

Must be either 'request' or 'response'.

@return [String] the configuration value for the json_format_header for

the given http message type
# File lib/sparrow/configuration.rb, line 47
def json_format_header(type)
  public_send("json_#{type}_format_header")
end