Response Adapter¶
response_adapter
¶
Protocol for translating application output into transport-level responses.
ResponseAdapter
¶
Bases: Protocol
Translates application-layer output into a transport response.
Implementations handle transport-specific serialization (e.g.
JSON encoding, setting HTTP status headers, formatting CLI
output) and produce the raw response type consumed by the
transport framework.
Source code in src/forging_blocks/presentation/response_adapter.py
adapt(output: UseCaseOutput) -> RawResponse
¶
Convert successful use-case output into a transport response.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output
|
UseCaseOutput
|
The value returned by |
required |
Returns:
| Type | Description |
|---|---|
RawResponse
|
A transport-level response ready to send to the caller. |
Source code in src/forging_blocks/presentation/response_adapter.py
adapt_error(view_model: ErrorViewModel) -> RawResponse
¶
Convert an ErrorViewModel into a transport error response.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
view_model
|
ErrorViewModel
|
The error view model produced by |
required |
Returns:
| Type | Description |
|---|---|
RawResponse
|
A transport-level error response (e.g. an HTTP response |
RawResponse
|
with the appropriate status code and JSON body). |