Skip to content

Add possibility to access raw body when executing client call #2114

@matwojcik

Description

@matwojcik

I'd like to access raw response body when my client call fails, so e.g. I can log it.

Right now if I have an endpoint: Endpoint[Unit,Unit,Nothing,Unit,Any] and do SttpClientInterpreter(SttpClientOptions.default).toRequest(endpoint, uri)(wsToPipe)(params).send(backend) I receive Response[DecodeResult[Either[E, O]]]. If this is unmapped error like 500, then we get Error(,java.lang.IllegalArgumentException: Cannot decode from: , request: GET http://localhost) which doesn't bring much value.

Usually I'd like to have the raw body in hand in such cases and log it.

I can see that in sttp there was similar issue softwaremill/sttp#190 which was implemented with asBoth, however in tapir we don't have control over it (at least I can't see such option).

At the same time I wouldn't like to change my original endpoint to have raw String in response.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions