mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 20:30:23 +00:00

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.
28 lines
503 B
Erlang
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.
|