Module: API::Helpers::HeadersHelpers

Includes:
Gitlab::NoCacheHeaders
Defined in:
lib/api/helpers/headers_helpers.rb

Constant Summary

Constants included from Gitlab::NoCacheHeaders

Gitlab::NoCacheHeaders::DEFAULT_GITLAB_NO_CACHE_HEADERS

Instance Method Summary collapse

Instance Method Details

#no_cache_headersObject


18
19
20
21
22
# File 'lib/api/helpers/headers_helpers.rb', line 18

def no_cache_headers
  DEFAULT_GITLAB_NO_CACHE_HEADERS.each do |k, v|
    header k, v
  end
end

#set_http_headers(header_data) ⇒ Object


8
9
10
11
12
13
14
15
16
# File 'lib/api/helpers/headers_helpers.rb', line 8

def set_http_headers(header_data)
  header_data.each do |key, value|
    if value.is_a?(Enumerable)
      raise ArgumentError.new("Header value should be a string")
    end

    header "X-Gitlab-#{key.to_s.split('_').collect(&:capitalize).join('-')}", value.to_s
  end
end