mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 20:30:23 +00:00
Convert the markdown_middleware example to a release
This commit is contained in:
parent
4769412daa
commit
36ba174224
9 changed files with 1614 additions and 46 deletions
1581
examples/markdown_middleware/src/erlmarkdown.erl
Normal file
1581
examples/markdown_middleware/src/erlmarkdown.erl
Normal file
File diff suppressed because it is too large
Load diff
|
@ -22,8 +22,8 @@ maybe_generate_markdown(Path) ->
|
|||
end.
|
||||
|
||||
resource_path(Path) ->
|
||||
{ok, Cwd} = file:get_cwd(),
|
||||
filename:join([Cwd, "priv", Path]).
|
||||
PrivDir = code:priv_dir(markdown_middleware),
|
||||
filename:join([PrivDir, Path]).
|
||||
|
||||
source_path(Path) ->
|
||||
<< (filename:rootname(Path))/binary, ".md" >>.
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
%% Feel free to use, reuse and abuse the code in this file.
|
||||
|
||||
-module(markdown_middleware).
|
||||
|
||||
%% 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(markdown_middleware).
|
|
@ -15,7 +15,11 @@ start(_Type, _Args) ->
|
|||
{'_', [
|
||||
{"/[...]", cowboy_static, [
|
||||
{directory, {priv_dir, markdown_middleware, []}},
|
||||
{mimetypes, {fun mimetypes:path_to_mimes/2, default}}
|
||||
{mimetypes, [
|
||||
{<<".html">>, [<<"text/html">>]},
|
||||
{<<".mp4">>, [<<"video/mp4">>]},
|
||||
{<<".ogv">>, [<<"video/ogg">>]}
|
||||
]}
|
||||
]}
|
||||
]}
|
||||
]),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue