mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-15 20:50:24 +00:00

They are now cowboy:start_clear/3 and cowboy:start_tls/3. The NumAcceptors argument can be specified via the num_acceptor transport option. Ranch has been updated to 1.4.0 to that effect.
26 lines
569 B
Erlang
26 lines
569 B
Erlang
%% Feel free to use, reuse and abuse the code in this file.
|
|
|
|
%% @private
|
|
-module(websocket_app).
|
|
-behaviour(application).
|
|
|
|
%% API.
|
|
-export([start/2]).
|
|
-export([stop/1]).
|
|
|
|
%% API.
|
|
start(_Type, _Args) ->
|
|
Dispatch = cowboy_router:compile([
|
|
{'_', [
|
|
{"/", cowboy_static, {priv_file, websocket, "index.html"}},
|
|
{"/websocket", ws_handler, []},
|
|
{"/static/[...]", cowboy_static, {priv_dir, websocket, "static"}}
|
|
]}
|
|
]),
|
|
{ok, _} = cowboy:start_clear(http, [{port, 8080}], #{
|
|
env => #{dispatch => Dispatch}
|
|
}),
|
|
websocket_sup:start_link().
|
|
|
|
stop(_State) ->
|
|
ok.
|