NOTE: Read this if you want to pass the App
name as the second argument to
leptus:start_listener/2
.
Leptus configuration file must be named leptus.config
and put in priv
directory.
Your request handlers should be defined as
{handlers, [{HostMatch, [{module(), State :: any()}]}]}.
in leptus.config
IP address and port number have default values: 127.0.0.1:8080
, but you
can override them as follows:
{options,
[
{ip, inet:ip_address()},
{port, inet:port_number()}
]
}.
Note: For HTTPS and SPDY you also need to specify cacertfile
, certfile
and keyfile
:
{options,
[
{cacertfile, file:name()},
{certfile, file:name()},
{keyfile, file:name()}
]
}.
%% leptus.config
{options,
[
{ip, {0, 0, 0, 0}},
{port, 4444},
{cacertfile, "ssl/ca.crt"},
{certfile, "ssl/server.crt"},
{keyfile, "ssl/server.key"}
]
}.
{handlers,
[
{'_',
[{rq_handler1, undefined_state},
{rq_handler2, [admin, dev]}]
}
]
}.