Stopsel.Router (stopsel v0.1.0) View Source

This module is responsible for managing the active routes of a router.

A router must first be loaded, before it can be used.

iex> Stopsel.Router.load_router(MyApp.Router)
:ok

After that we can use unload routes, enable them again or even unload the whole router.

iex> Stopsel.Router.unload_route(MyApp.Router, ~w"hello")
:ok
iex> Stopsel.Router.load_route(MyApp.Router, ~w"hello")
:ok
iex> Stopsel.Router.unload_router(MyApp.Router)
:ok

Link to this section Summary

Functions

Loads one route that was previously removed back into the router.

Loads all commands from the given module into the router.

Tries to find a matching route in the given router.

Returns a list of all the currently active routes of the router.

Unloads one route from the router.

Removes the given module from the router.

Link to this section Types

Specs

assigns() :: map()

Specs

match() :: {[{stopsel(), opts()}], function(), assigns(), params()}

Specs

match_error() :: :no_match | {:multiple_matches, [match()]}

Specs

opts() :: any()

Specs

params() :: map()

Specs

path() :: [String.t()]

Specs

router() :: module()

Specs

stopsel() :: module() | function()

Link to this section Functions

Link to this function

load_route(router, path)

View Source

Specs

load_route(router(), path()) :: boolean()

Loads one route that was previously removed back into the router.

Specs

load_router(router()) :: true

Loads all commands from the given module into the router.

Reloads all routes of the router, if they have been unloaded.

Link to this function

match_route(router, path)

View Source

Specs

match_route(router(), path()) :: {:ok, match()} | {:error, match_error()}

Tries to find a matching route in the given router.

Specs

routes(router()) :: [[String.t()]]

Returns a list of all the currently active routes of the router.

Link to this function

unload_route(router, path)

View Source

Specs

unload_route(router(), path()) :: boolean()

Unloads one route from the router.

Specs

unload_router(router()) :: boolean()

Removes the given module from the router.