Skip to content

Request Adapter

request_adapter

Protocol for translating transport-level requests into application input.

RequestAdapter

Bases: Protocol

Translates a raw transport request into application-layer input.

Implementations handle transport-specific deserialization (e.g.
parsing JSON bodies, extracting headers, normalising query
parameters) and produce a typed use-case input DTO or command.

Source code in src/forging_blocks/presentation/request_adapter.py
class RequestAdapter[RawRequest, UseCaseInput](Protocol):
    """Translates a raw transport request into application-layer input.

    Implementations handle transport-specific deserialization (e.g.
    parsing JSON bodies, extracting headers, normalising query
    parameters) and produce a typed use-case input DTO or command.
    """

    def adapt(self, raw: RawRequest) -> UseCaseInput:
        """Convert *raw* transport data into use-case input.

        Args:
            raw: The transport-level request (e.g. an HTTP request
                object, a CLI argv tuple, or a raw dictionary).

        Returns:
            A typed input value suitable for passing to a
            ``UseCase.execute`` call.
        """
        ...

adapt(raw: RawRequest) -> UseCaseInput

Convert raw transport data into use-case input.

Parameters:

Name Type Description Default
raw RawRequest

The transport-level request (e.g. an HTTP request
object, a CLI argv tuple, or a raw dictionary).

required

Returns:

Type Description
UseCaseInput

A typed input value suitable for passing to a

UseCaseInput

UseCase.execute call.

Source code in src/forging_blocks/presentation/request_adapter.py
def adapt(self, raw: RawRequest) -> UseCaseInput:
    """Convert *raw* transport data into use-case input.

    Args:
        raw: The transport-level request (e.g. an HTTP request
            object, a CLI argv tuple, or a raw dictionary).

    Returns:
        A typed input value suitable for passing to a
        ``UseCase.execute`` call.
    """
    ...