diff options
author | Andrei Nesterov <[email protected]> | 2016-03-06 19:30:17 +0300 |
---|---|---|
committer | Andrei Nesterov <[email protected]> | 2016-06-07 21:36:15 +0300 |
commit | b448c4fde627f27793b74965043e113f78cfb8d0 (patch) | |
tree | f3a74a4d32e3b20fa53700fca99c57a1fac11b6f | |
parent | d670823e87ff7927638176d5025ae8ff227785ab (diff) | |
download | cowlib-b448c4fde627f27793b74965043e113f78cfb8d0.tar.gz cowlib-b448c4fde627f27793b74965043e113f78cfb8d0.tar.bz2 cowlib-b448c4fde627f27793b74965043e113f78cfb8d0.zip |
Add cow_http_hd:access_control_max_age/1
-rw-r--r-- | src/cow_http_hd.erl | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/cow_http_hd.erl b/src/cow_http_hd.erl index 4207b19..4496949 100644 --- a/src/cow_http_hd.erl +++ b/src/cow_http_hd.erl @@ -117,6 +117,7 @@ -export([access_control_allow_methods/1]). -export([access_control_allow_origin/1]). -export([access_control_expose_headers/1]). +-export([access_control_max_age/1]). -type etag() :: {weak | strong, binary()}. -export_type([etag/0]). @@ -3344,6 +3345,24 @@ horse_access_control_expose_headers() -> ). -endif. +%% @doc Build the Access-Control-Max-Age header. + +-spec access_control_max_age(non_neg_integer()) -> iodata(). +access_control_max_age(MaxAge) -> integer_to_binary(MaxAge). + +-ifdef(TEST). +access_control_max_age_test_() -> + Tests = [ + {0, <<"0">>}, + {42, <<"42">>}, + {69, <<"69">>}, + {1337, <<"1337">>}, + {3495, <<"3495">>}, + {1234567890, <<"1234567890">>} + ], + [{V, fun() -> R = access_control_max_age(V) end} || {V, R} <- Tests]. +-endif. + %% Internal. %% Only return if the list is not empty. |