heimdall v0.3.1 Heimdall.DynamicRoutes
Module for dynamically registering routes and routing requests.
This is where most of the magic happens. All traffic through the application is routed through this plug.
Routes are stored in an ETS table to be looked up when the plug
is called. When called Heimdall.DynamicRoutes
search for a route
that matches the request, wrap all plugs in the route into one function
and call it with the current request. The final plug in the chain will
always be Heimdall.Plug.ForwardRequest
Summary
Functions
Returns the route in given routes that matches a path as a list (which
is how plug conns reperesent them internally). Will return :no_routes
if no routes are found
Registers a route for later lookup
Unregisters a route given its host and path
Unregisters all routes for a give table
Functions
Returns the route in given routes that matches a path as a list (which
is how plug conns reperesent them internally). Will return :no_routes
if no routes are found.
Examples
iex> Heimdall.DynamicRoutes.lookup_path([{"localhost", ["test", "path"], [], {}}], ["test", "path"])
{"localhost", ["test", "path"], [], {}}
iex> Heimdall.DynamicRoutes.lookup_path([{"localhost", ["test", "path"], [], {}}], ["test", "path", "but", "longer"])
{"localhost", ["test", "path"], [], {}}