alice v0.2.1 Alice.Router

Summary

Functions

Returns a list of the currently registered handlers

Used internally to match command handlers

Used internally to match route handlers

Registers a handler. Returns :ok

Starts a Alice.Router process linked to the current process

Functions

handlers(pid \\ Alice.Router)

Returns a list of the currently registered handlers.

If you started the router with default options, then you don’t have to pass in a pid. (It will use the default registered name Alice.Router.

match_commands(conn)

Used internally to match command handlers

match_routes(conn)

Used internally to match route handlers

register_handler(pid \\ Alice.Router, handler)

Registers a handler. Returns :ok

start_link(handlers \\ [], opts \\ [name: Alice.Router])

Starts a Alice.Router process linked to the current process.

Note that a process started with start_link/2 is linked to the parent process and will exit in case of crashes.

Options

You can pass in a list of handlers to be registered immediately upon starting the Router process.

For other options, see GenServer.start_link/3. Default is to register the process with the name Alice.Router.

Return values

If the router is successfully created and initialized, the function returns {:ok, pid}, where pid is the pid of the router.