mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-15 04:30:25 +00:00
Convert the web_server example to a release
Temporary mimetypes list here too.
This commit is contained in:
parent
8bb7c180ff
commit
6a90d00cee
8 changed files with 37 additions and 50 deletions
|
@ -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]).
|
||||
|
|
|
@ -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).
|
|
@ -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">>]}
|
||||
]}
|
||||
]}
|
||||
]}
|
||||
]),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue