0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-14 20:30:23 +00:00
cowboy/examples/static/src/static_app.erl
dbmercer b5fdf02af0 Modified static example to send appropriate MIME type
Modified the static example in the examples subdirectory
to use the mimetypes application to determine the appropriate
MIME type to send down the wire in the HTTP headers of the reply.
2012-10-11 20:47:35 +02:00

28 lines
503 B
Erlang

%% Feel free to use, reuse and abuse the code in this file.
%% @private
-module(static_app).
-behaviour(application).
%% API.
-export([start/2]).
-export([stop/1]).
%% API.
start(_Type, _Args) ->
Dispatch = [
{'_', [
{['...'], cowboy_static, [
{directory, {priv_dir, static, []}},
{mimetypes, {fun mimetypes:path_to_mimes/2, default}}
]}
]}
],
{ok, _} = cowboy:start_http(http, 100, [{port, 8080}], [
{dispatch, Dispatch}
]),
static_sup:start_link().
stop(_State) ->
ok.