UP | HOME

leptus

Module

leptus

Types

Listener  = http | https
Handlers  = [{HostMatch, [{module(), State :: any()}]}]

HostMatch = term()
StaticDir = file:name() | {priv_dir, App :: atom(), Dir :: file:name()}

Option = {ip, inet:ip_address()}
       | {port, inet:port_number()}
       | {num_acceptors, non_neg_integer()}
       | {cacertfile, file:name_all()}
       | {certfile, file:name_all()}
       | {keyfile, file:name_all()}
       | {static_dir, {HostMatch, StaticDir}}
       | {log_handlers, [{module(), any()}]}
Options = [Option]

Functions

start_listener/2

Starts a listener of type Listener.

leptus:start_listener(Listener, HandlersOrApp) -> {ok, pid()}

App = atom()
HandlersOrApp = Handlers | App

Note that if you specify App, Leptus will try to evaluate App/priv/leptus.config file which should contain:

{handlers, Handlers}.
{options, Options}.

start_listener/3

leptus:start_listener(Listener, Handlers, Options) ->
    leptus:start_listener(Listener, Handlers, Options, #{})

start_listener/4

Starts a listener of type Listener.

leptus:start_listener(Listener, Handlers, Options, CowboyProtoOpts) ->
    {ok, pid()}

CowboyProtoOpts = cowboy:opts()

upgrade/0

Upgrades running listeners.

upgrade() -> upgrade([Listener])

upgrade/1

Upgrades the given listeners.

upgrade([Listener]) -> ok

upgrade/2

upgrade(Listener, Handlers) -> upgrade(Listener, Handlers, Options)

upgrade/3

Upgrades an running listener to switch to Handlers and Options.

upgrade(Listener, Handlers, Options) -> ok

stop_listener/1

Stops a listener.

stop_listener(Listener) -> ok | {error, not_found}

running_listeners/0

Lists running listeners.

running_listeners() -> [Listener]

listener_uptime/1

Gives the uptime of a listener.

listener_uptime(Listener) - >
    {Days :: integer(), calendar:time()} | {error, not_found}

Author: Sina Samavati

Created: 2018-09-19