ResponseAs

sttp.client4.ResponseAs
See theResponseAs companion object
case class ResponseAs[+T](delegate: GenericResponseAs[T, Any]) extends ResponseAsDelegate[T, Any]

Describes how the response body of a Request should be handled.

Apart from the basic cases (ignoring, reading as a byte array or file), response body descriptions can be mapped over, to support custom types. The mapping can take into account the ResponseMetadata, that is the headers and status code. Responses can also be handled depending on the response metadata. Finally, two response body descriptions can be combined (with some restrictions).

A number of as<Type> helper methods are available as part of SttpApi and when importing sttp.client4._.

Type parameters

T

Target type as which the response will be read.

Attributes

Companion
object
Graph
Supertypes
trait Serializable
trait Product
trait Equals
trait ResponseAsDelegate[T, Any]
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

def getEither: ResponseAs[Either[HE, B]]

If the type to which the response body should be deserialized is an Either[ResponseException[HE, DE], B], either throws the DeserializationException, returns the deserialized body from the HttpError, or the deserialized successful body B.

If the type to which the response body should be deserialized is an Either[ResponseException[HE, DE], B], either throws the DeserializationException, returns the deserialized body from the HttpError, or the deserialized successful body B.

Attributes

Implicitly added by RichResponseAsEither

If the type to which the response body should be deserialized is an Either[A, B]:

If the type to which the response body should be deserialized is an Either[A, B]:

  • in case of A, throws as an exception / returns a failed effect (wrapped with an HttpError if A is not yet an exception)
  • in case of B, returns the value directly

Attributes

def map[T2](f: T => T2): ResponseAs[T2]
def mapLeft[L2](f: A => L2): ResponseAs[Either[L2, B]]
Implicitly added by RichResponseAsEither
def mapRight[R2](f: B => R2): ResponseAs[Either[A, R2]]
Implicitly added by RichResponseAsEither
def mapWithMetadata[T2](f: (T, ResponseMetadata) => T2): ResponseAs[T2]
def showAs(s: String): ResponseAs[T]

Inherited methods

def productElementNames: Iterator[String]

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

Attributes

Inherited from:
Product
def show: String

Attributes

Inherited from:
ResponseAsDelegate