Using as an http4s client
Add the dependency:
"com.softwaremill.sttp.tapir" %% "tapir-http4s-client" % "0.19.0-M16"
To interpret an endpoint definition as an
This objects contains four methods:
toSecureRequestUnsafe(Endpoint, Option[Uri]): given the optional base URI, returns a function which generates a request and a response parser from endpoint inputs. Response parser throws an exception if decoding of the result fails.
I => (org.http4s.Request[F], org.http4s.Response[F] => F[Either[E, O]])
toSecureRequest(Endpoint, Option[Uri]): given the optional base URI, returns a function which generates a request and a response parser from endpoint inputs. Response parser returns an instance of
DecodeResultwhich contains the decoded response body or error details.
I => (org.http4s.Request[F], org.http4s.Response[F] => F[DecodeResult[Either[E, O]]])
Note that the returned functions have one argument each: first the security inputs (if any), and regular input values of the endpoint. This might be a single type, a tuple, or a case class, depending on the endpoint description.
After providing the input parameters, the following values are returned:
An instance of
org.http4s.Request[F]with the input value encoded as appropriate request parameters: path, query, headers and body. The request can be further customised and sent using an http4s client, or run against
A response parser to be applied to the response received after executing the request. The result will then contain the decoded error or success values (note that this can be the body enriched with data from headers/status code).
See the runnable example for example usage.
Multipart requests are not supported yet.
WebSockets are not supported yet.
Fs2Streamsare supported at the moment.