Module: JSONAPI::Parser::HeadersParser

Defined in:
lib/easy/jsonapi/parser/headers_parser.rb

Overview

Header parsing logic

Class Method Summary collapse

Class Method Details

.parse(env) ⇒ JSONAPI::HeaderCollection

Returns The collection of parsed header objects.

Parameters:

  • env (Hash)

    The rack envirornment hash

Returns:



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/easy/jsonapi/parser/headers_parser.rb', line 19

def self.parse(env)
  h_collection = JSONAPI::HeaderCollection.new
  env.each_key do |k|
    if k.start_with?('HTTP_') && (k != 'HTTP_VERSION')
      h_collection << JSONAPI::HeaderCollection::Header.new(k[5..-1], env[k])
    elsif k == 'CONTENT_TYPE'
      h_collection << JSONAPI::HeaderCollection::Header.new(k, env[k])
    end
  end
  h_collection
end