Coverage for src / lexigram / contracts / web / execution_context.py: 100%
15 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-08-19 05:41 +0800
« prev ^ index » next coverage.py v7.13.5, created at 2026-08-19 05:41 +0800
1"""Execution context protocol for the web framework.
3Kept in lexigram-contracts so that GuardProtocol (also in contracts) can
4reference it without taking a dependency on lexigram-web.
5"""
7from __future__ import annotations
9from typing import TYPE_CHECKING, Any, Protocol, runtime_checkable
11if TYPE_CHECKING:
12 from collections.abc import Callable
15@runtime_checkable
16class ExecutionContextProtocol(Protocol):
17 """Provides metadata about the current request being processed.
19 Used by interceptors and guards to access request information and make
20 decisions about how to process the request/response.
21 """
23 @property
24 def request(self) -> Any:
25 """The current HTTP request."""
26 ...
28 @property
29 def handler(self) -> Callable[..., Any]:
30 """The handler function that will be called."""
31 ...
33 @property
34 def controller_class(self) -> type | None:
35 """The controller class, if this is a controller method."""
36 ...
38 @property
39 def method_name(self) -> str | None:
40 """The name of the method being called."""
41 ...
43 @property
44 def route_metadata(self) -> dict[str, Any]:
45 """Metadata about the route."""
46 ...
49__all__ = ["ExecutionContextProtocol"]