An endpoint. params, query and headers are the string
tree codecs of their schemas, payload the payload schemas by
content type, success and error the response schemas (their
JSON codecs unless disable_codecs).
Attributes#
| Attribute | Type | Description |
|---|---|---|
identifier | str | |
method | HttpMethod | |
path | str | |
params | Top | None = None | |
query | Top | None = None | |
headers | Top | None = None | |
payload | PayloadMap = field(default_factory=(dict[str, PayloadEntry])) | |
success | tuple[Top, ...] = () | |
error | tuple[Top, ...] = () | |
annotations | Context[Any] = field(default_factory=(Context.empty)) | |
middlewares | tuple[AnyMiddleware, ...] = () | |
disable_codecs | bool = False |
Functions#
__init__#
__init__(identifier, method, path, params=None, query=None, headers=None, payload=dict[str, PayloadEntry](), success=(), error=(), annotations=Context.empty(), middlewares=(), disable_codecs=False) -> None| Parameter | Type | Description |
|---|---|---|
identifier | str | |
method | HttpMethod | |
path | str | |
params | Top | None = None | |
query | Top | None = None | |
headers | Top | None = None | |
payload | PayloadMap = dict[str, PayloadEntry]() | |
success | tuple[Top, ...] = () | |
error | tuple[Top, ...] = () | |
annotations | Context[Any] = Context.empty() | |
middlewares | tuple[AnyMiddleware, ...] = () | |
disable_codecs | bool = False |
prefix#
prefix(prefix) -> SelfThis endpoint under prefix.
| Parameter | Type | Description |
|---|---|---|
prefix | str |
Returns Self
def prefix(self, prefix: str) -> Self:
"""This endpoint under ``prefix``."""
return replace(self, path=prefix_path(self.path, prefix))middleware#
middleware[T: HttpApiMiddleware[Any, Any, Any]](middleware) -> HttpApiEndpoint[P_co, Q_co, B_co, CB_co, H_co, S, CS_co, E, M_co | T, MT_co | T]This endpoint wrapped by middleware: its handler may fail
with the middleware's errors, a client too, and the services it
provides are the handler's. The group layer needs the middleware.
| Parameter | Type | Description |
|---|---|---|
middleware | type[T] |
Returns HttpApiEndpoint[P_co, Q_co, B_co, CB_co, H_co, S, CS_co, E, M_co | T, MT_co | T]
def middleware[T: HttpApiMiddleware[Any, Any, Any]](
self, middleware: type[T], /
) -> HttpApiEndpoint[P_co, Q_co, B_co, CB_co, H_co, S, CS_co, E, M_co | T, MT_co | T]:
"""This endpoint wrapped by ``middleware``: its handler may fail
with the middleware's errors, a client too, and the services it
provides are the handler's. The group layer needs the middleware."""
if middleware in self.middlewares:
return self
return replace(self, middlewares=(*self.middlewares, middleware))annotate#
annotate[A, T](tag, value) -> SelfThis endpoint with an annotation (OpenApi.Summary, ...).
| Parameter | Type | Description |
|---|---|---|
tag | TagLike[A, T] | |
value | A |
Returns Self
def annotate[A, T](self, tag: TagLike[A, T], value: A) -> Self:
"""This endpoint with an annotation (``OpenApi.Summary``, ...)."""
return replace(self, annotations=self.annotations.add(tag, value))annotate_merge#
annotate_merge(annotations) -> Self| Parameter | Type | Description |
|---|---|---|
annotations | Context[Any] |
Returns Self
def annotate_merge(self, annotations: Context[Any]) -> Self:
return replace(self, annotations=self.annotations.merge(annotations))pipe#
pipe[A](f) -> A| Parameter | Type | Description |
|---|---|---|
f | Callable[[Self], A] |
Returns A
def pipe[A](self, f: Callable[[Self], A], /) -> A:
return f(self)