aboutsummaryrefslogtreecommitdiffstats
path: root/examples/web_server/src
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2013-09-09 16:10:58 +0200
committerLoïc Hoguin <[email protected]>2013-09-09 16:10:58 +0200
commit6a90d00ceee9c95d5d80190736e04f35bd04d8f4 (patch)
treec9a388e324260d0213bdf7fd354a8eed06e6eb0f /examples/web_server/src
parent8bb7c180ff3a169557e24c8eb7e3e8e4b5645cbf (diff)
downloadcowboy-6a90d00ceee9c95d5d80190736e04f35bd04d8f4.tar.gz
cowboy-6a90d00ceee9c95d5d80190736e04f35bd04d8f4.tar.bz2
cowboy-6a90d00ceee9c95d5d80190736e04f35bd04d8f4.zip
Convert the web_server example to a release
Temporary mimetypes list here too.
Diffstat (limited to 'examples/web_server/src')
-rw-r--r--examples/web_server/src/directory_lister.erl3
-rw-r--r--examples/web_server/src/web_server.erl15
-rw-r--r--examples/web_server/src/web_server_app.erl7
3 files changed, 7 insertions, 18 deletions
diff --git a/examples/web_server/src/directory_lister.erl b/examples/web_server/src/directory_lister.erl
index a59f957..aa36314 100644
--- a/examples/web_server/src/directory_lister.erl
+++ b/examples/web_server/src/directory_lister.erl
@@ -33,5 +33,4 @@ valid_path([<<"/", _/binary>> | _T]) -> false;
valid_path([_H | Rest]) -> valid_path(Rest).
resource_path(Path) ->
- {ok, Cwd} = file:get_cwd(),
- filename:join([Cwd, "priv", Path]).
+ filename:join([code:priv_dir(web_server), Path]).
diff --git a/examples/web_server/src/web_server.erl b/examples/web_server/src/web_server.erl
deleted file mode 100644
index ac3f1b1..0000000
--- a/examples/web_server/src/web_server.erl
+++ /dev/null
@@ -1,15 +0,0 @@
-%% Feel free to use, reuse and abuse the code in this file.
-
--module(web_server).
-
-%% API.
--export([start/0]).
-
-%% API.
-
-start() ->
- ok = application:start(crypto),
- ok = application:start(cowlib),
- ok = application:start(ranch),
- ok = application:start(cowboy),
- ok = application:start(web_server).
diff --git a/examples/web_server/src/web_server_app.erl b/examples/web_server/src/web_server_app.erl
index 43dc078..988a8fb 100644
--- a/examples/web_server/src/web_server_app.erl
+++ b/examples/web_server/src/web_server_app.erl
@@ -16,7 +16,12 @@ start(_Type, _Args) ->
{"/[...]", cowboy_static, [
{directory, {priv_dir, web_server, []}},
{dir_handler, directory_handler},
- {mimetypes, {fun mimetypes:path_to_mimes/2, default}}
+ {mimetypes, [
+ {<<".html">>, [<<"text/html">>]},
+ {<<".txt">>, [<<"text/plain">>]},
+ {<<".mp4">>, [<<"video/mp4">>]},
+ {<<".ogv">>, [<<"video/ogg">>]}
+ ]}
]}
]}
]),