Method: Telnyx::Util.normalize_headers
- Defined in:
- lib/telnyx/util.rb
.normalize_headers(headers) ⇒ Object
Normalizes header keys so that they’re all lower case and each hyphen-delimited section starts with a single capitalized letter. For example, ‘request-id` becomes `Request-Id`. This is useful for extracting certain key values when the user could have set them with a variety of diffent naming schemes.
227 228 229 230 231 232 233 234 |
# File 'lib/telnyx/util.rb', line 227 def self.normalize_headers(headers) headers.each_with_object({}) do |(k, v), new_headers| k = k.to_s.tr("_", "-") if k.is_a?(Symbol) k = k.split("-").reject(&:empty?).map(&:capitalize).join("-") new_headers[k] = v end end |