Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 1f8ff38db3
Fetching contributors…

Cannot retrieve contributors at this time

23 lines (19 sloc) 0.708 kb
-module(simple_bridge_util).
-export([atomize_header/1]).
%% converts a Header to a lower-case, underscored version
%% ie. "X-Forwarded-For" -> x_forwarded_for
atomize_header(Header) when is_binary(Header) ->
atomize_header(binary_to_list(Header));
atomize_header(Header) when is_atom(Header) ->
atomize_header(atom_to_list(Header));
atomize_header(Header) when is_list(Header) ->
LowerUnderscore = fun(H) ->
if
H >= 65 andalso H =< 90 ->
H + 32; % Convert "A" to "a" by adding 32 to its ASCII val
H == 45 ->
95; %% convert "-" to "_"
true -> H
end
end,
list_to_atom(lists:map(LowerUnderscore,Header)).
Jump to Line
Something went wrong with that request. Please try again.