From 54d16c14ad4e91489a297d4bd4031d2b546d7963 Mon Sep 17 00:00:00 2001 From: Magnus Klaar Date: Wed, 4 Jan 2012 02:22:21 +0100 Subject: Add test and doc for content types function. --- src/cowboy_http_static.erl | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src') diff --git a/src/cowboy_http_static.erl b/src/cowboy_http_static.erl index a98026d..94ba6cd 100644 --- a/src/cowboy_http_static.erl +++ b/src/cowboy_http_static.erl @@ -65,13 +65,25 @@ %% The mimetypes must be of a type that the `cowboy_http_rest' protocol can %% handle. %% +%% The spawngrid/mimetypes +%% application, or an arbitrary function accepting the path to the file being +%% served, can also be used to generate the list of content types for a static +%% file resource. The function used must accept an additional argument after +%% the file path argument. +%% %% ==== Example ==== %% ``` +%% %% Use a static list of content types. %% {[<<"static">>, '...'], cowboy_http_static, %% [{directory, {priv_dir, cowboy, []}}, %% {mimetypes, [ %% {<<".css">>, [<<"text/css">>]}, %% {<<".js">>, [<<"application/javascript">>]}]}]} +%% +%% %% Use the default database in the mimetypes application. +%% {[<<"static">>, '...', cowboy_http_static, +%% [{directory, {priv_dir, cowboy, []}}, +%% {mimetypes, {fun mimetypes:path_to_mimes/2, default}}]]} %% ''' -module(cowboy_http_static). -- cgit v1.2.3