Skip to content

Context

faststream.broker.fastapi.context.Context #

Context(name, *, default=EMPTY, initial=None)

Get access to objects of the Context.

Source code in faststream/broker/fastapi/context.py
def Context(  # noqa: N802
    name: str,
    *,
    default: Any = EMPTY,
    initial: Optional[Callable[..., Any]] = None,
) -> Any:
    """Get access to objects of the Context."""
    return params.Depends(
        lambda: resolve_context_by_name(
            name=name,
            default=default,
            initial=initial,
        ),
        use_cache=True,
    )