HttpReadsInstances

uk.gov.hmrc.http.HttpReadsInstances
See theHttpReadsInstances companion trait

Attributes

Companion
trait
Graph
Supertypes
trait HttpReadsTry
class Object
trait Matchable
class Any
Show all
Self type

Members list

Value members

Inherited methods

def throwOnFailure[A](reads: HttpReads[Either[UpstreamErrorResponse, A]]): HttpReads[A]

Attributes

Inherited from:
HttpReadsEither

Implicits

Inherited implicits

implicit def readEitherOf[A : HttpReads]: HttpReads[Either[UpstreamErrorResponse, A]]

Attributes

Inherited from:
HttpReadsEither
implicit def readFromJson[A](implicit rds: Reads[A], ct: ClassTag[A]): HttpReads[A]

This is probably the typical instance to use, since all http calls occur within Future, allowing recovery.

This is probably the typical instance to use, since all http calls occur within Future, allowing recovery.

Attributes

Inherited from:
LowPriorityHttpReadsJson
implicit def readJsResult[A : Reads]: HttpReads[JsResult[A]]

Note to read json regardless of error response - can define your own:

Note to read json regardless of error response - can define your own:

 HttpReads[HttpResponse].map(_.json.validate[A])

or custom behaviour - define your own:

HttpReads[HttpResponse].map(response => response.status match {
 case 200   => Right(response.body.json.validate[A])
 case 400   => Right(response.body.json.validate[A])
 case other => Left(s"Invalid status code: $other")
})

Attributes

Inherited from:
HttpReadsJson
implicit val readJsValue: HttpReads[JsValue]

Attributes

Inherited from:
HttpReadsJson
implicit def readOptionOfNotFound[A : HttpReads]: HttpReads[Option[A]]

An opinionated HttpReads which returns None for 404. This does not have any special treatment for 204, as did the previous version. If you need a None for any UpstreamErrorResponse, consider using:

An opinionated HttpReads which returns None for 404. This does not have any special treatment for 204, as did the previous version. If you need a None for any UpstreamErrorResponse, consider using:

HttpReads[Either[UpstreamErrorResponse, A]].map(_.toOption)

Attributes

Inherited from:
HttpReadsOption
implicit val readRaw: HttpReads[HttpResponse]

returns the HttpResponse as is - you will be responsible for checking any status codes.

returns the HttpResponse as is - you will be responsible for checking any status codes.

Attributes

Inherited from:
HttpReadsHttpResponse
implicit def readTryOf[A : HttpReads]: HttpReads[Try[A]]

Attributes

Inherited from:
HttpReadsTry
implicit val readUnit: HttpReads[Unit]

Ignores the response and returns Unit - useful for handling 204 etc. It can be combined with error handling types (e.g. Either[UpstreamErrorResponse, Unit])

Ignores the response and returns Unit - useful for handling 204 etc. It can be combined with error handling types (e.g. Either[UpstreamErrorResponse, Unit])

Attributes

Inherited from:
HttpReadsHttpResponse