gen_router v0.1.0 GenRouter.Conn

Structure which represents connection with Telegram bot. Inspired by %Plug.Conn{}, adapted for bots.

Attributes:

  • skip: system buffer to keep track of skipped scopes;
  • path: route to controller which should handle this object;
  • params: payload which will be passed to controller;
  • assigns: non-parsed data assigned by a system (auth, etc);
  • scope: local scope of current request, clears for each new route;
  • code: response code, we use common HTTP codes, currently only 200 is supported.
  • response: response payload, usually JSON

Link to this section Summary

Functions

Assign variable to current request

Build Conn object with system fields

Update state and complete the current request

Put the next path after the current request

Link to this section Types

Link to this type

t()
t() :: %GenRouter.Conn{
  __skip__: term(),
  assigns: term(),
  code: term(),
  params: term(),
  path: term(),
  response: term(),
  scope: term()
}

Link to this section Functions

Link to this function

assign(conn, key, value)
assign(t(), atom(), any()) :: t()

Assign variable to current request.

Link to this function

build(router_module, map)
build(module(), map()) :: t()

Build Conn object with system fields

Link to this function

complete(conn, response \\ nil, scope \\ %{}, code \\ 200)
complete(t(), String.t() | nil, map(), integer()) :: t()

Update state and complete the current request.

Link to this function

forward(conn, path \\ "/", scope \\ %{}, opts \\ [])
forward(t(), String.t(), map(), Keyword.t()) :: t()

Put the next path after the current request.