class JsonResponder[T, RE]
What schema_json gives: call it with a value (and response
options) for its JSON response.
Functions#
__init__#
__init__(schema, options) -> None| Parameter | Type | Description |
|---|---|---|
schema | Codec[T, object, object, RE] | |
options | ParseOptions |
def __init__(self, schema: Codec[T, object, object, RE], options: ParseOptions) -> None:
self._encode = _body.json_schema(schema, **options)__call__#
__call__(body, **options) -> Effect[HttpServerResponse, _body.HttpBodyError, RE]| Parameter | Type | Description |
|---|---|---|
body | T | |
options | Unpack[ContentTypeOptions] = {} |
Returns Effect[HttpServerResponse, _body.HttpBodyError, RE]
def __call__(
self, body: T, **options: Unpack[ContentTypeOptions]
) -> Effect[HttpServerResponse, _body.HttpBodyError, RE]:
headers = _headers(options)
return self._encode(body, _content_type(options, headers)).map(
lambda encoded: _make(options, 200, headers, encoded)
)