ExGram.Middleware behaviour (ex_gram v0.65.0)

Copy Markdown View Source

Behaviour for creating middlewares.

Middlewares receive the context (ExGram.Cnt) and can modify it before passing it to the next middleware or handler. Use middlewares for authentication, logging, rate limiting, or enriching the context with additional data.

See the Middlewares guide for usage examples.

Summary

Types

opts()

@type opts() ::
  binary()
  | tuple()
  | atom()
  | integer()
  | float()
  | [opts()]
  | %{required(opts()) => opts()}

Callbacks

call(t, opts)

@callback call(ExGram.Cnt.t(), opts()) :: ExGram.Cnt.t()

init(opts)

(optional)
@callback init(opts()) :: opts()

Functions

add_extra(cnt, values)

add_extra(cnt, key, value)

halt(cnt)