GenRouter (gen_router v0.1.10)

Router to parse messages, modeled by the idea of simplified Plug.Conn router.

Summary

Functions

Custom router factory

Defines default route or a route inside a pipeline.

Defines a pipeline to send the connection through.

Defines a plug pipeline.

Defines a plug inside a pipeline.

Defines scope of routers with pipelines.

Types

route()

@type route() :: {String.t() | Regex.t(), atom(), atom()}

Functions

__using__(opts)

(macro)

Custom router factory

match(path, controller, action)

(macro)

Defines default route or a route inside a pipeline.

See pipeline/2 for more information.

match_in_scope(router_module, scope, routes, scope_pipeline, path_suffix, conn, opts)

@spec match_in_scope(
  module(),
  atom(),
  [route()],
  [atom()],
  String.t(),
  GenRouter.Conn.t(),
  Keyword.t()
) ::
  GenRouter.Conn.t()

Match specific route in scope of routes.

We ensure that all paths and suffixs are matched with slash for consistency.

pipe_through(pipes)

(macro)

Defines a pipeline to send the connection through.

See pipeline/2 for more information.

pipeline(pipe, list)

(macro)

Defines a plug pipeline.

Pipelines are defined at the router root and can be used from any scope.

plug(plug, opts \\ [])

(macro)

Defines a plug inside a pipeline.

See pipeline/2 for more information.

scope(scope, scope_path, list)

(macro)

Defines scope of routers with pipelines.