Http

sealed trait Http[-R, +E, -A, +B] extends A => ZIO[R, Option[E], B]

A functional domain to model Http apps using ZIO and that can work over any kind of request and response types.

Companion:
object
trait A => ZIO[R, Option[E], B]
class Object
trait Matchable
class Any
Http[R, E, A, B]

Value members

Concrete methods

final def *>[R1 <: R, E1 >: E, A1 <: A, C1](other: Http[R1, E1, A1, C1]): Http[R1, E1, A1, C1]

Alias for zipRight

Alias for zipRight

final def ++[R1 <: R, E1 >: E, A1 <: A, B1 >: B](other: Http[R1, E1, A1, B1]): Http[R1, E1, A1, B1]

Combines two Http into one.

Combines two Http into one.

final def <<<[R1 <: R, E1 >: E, A1 <: A, X](other: Http[R1, E1, X, A1]): Http[R1, E1, X, B]

Composes one Http app with another.

Composes one Http app with another.

final def <>[R1 <: R, E1, A1 <: A, B1 >: B](other: Http[R1, E1, A1, B1]): Http[R1, E1, A1, B1]

Runs self but if it fails, runs other, ignoring the result from self.

Runs self but if it fails, runs other, ignoring the result from self.

final def >>=[R1 <: R, E1 >: E, A1 <: A, C1](f: B => Http[R1, E1, A1, C1]): Http[R1, E1, A1, C1]

Alias for flatmap

Alias for flatmap

final def >>>[R1 <: R, E1 >: E, B1 >: B, C](other: Http[R1, E1, B1, C]): Http[R1, E1, A, C]

Pipes the output of one app into the other

Pipes the output of one app into the other

final def @@[R1 <: R, E1 >: E, A1 <: A, B1 >: B, A2, B2](mid: Middleware[R1, E1, A1, B1, A2, B2]): Http[R1, E1, A2, B2]

Attaches the provided middleware to the Http app

Attaches the provided middleware to the Http app

final def \/[R1 <: R, E1 >: E, C, D](other: Http[R1, E1, C, D]): Middleware[R1, E1, B, C, A, D]

Combines two Http instances into a middleware that works a codec for incoming and outgoing messages.

Combines two Http instances into a middleware that works a codec for incoming and outgoing messages.

final def absolve[E1 >: E, C](implicit ev: B <:< Either[E1, C]): Http[R, E1, A, C]

Returns an http app that submerges the error case of an Either into the Http. The inverse operation of Http.either.

Returns an http app that submerges the error case of an Either into the Http. The inverse operation of Http.either.

final def andThen[R1 <: R, E1 >: E, B1 >: B, C](other: Http[R1, E1, B1, C]): Http[R1, E1, A, C]

Named alias for >>>

Named alias for >>>

final def apply(a: A): ZIO[R, Option[E], B]

Consumes the input and executes the Http.

Consumes the input and executes the Http.

final def as[C](c: C): Http[R, E, A, C]

Makes the app resolve with a constant value

Makes the app resolve with a constant value

final def body(implicit eb: B <:< Response, ee: E <:< Throwable): Http[R, Throwable, A, Chunk[Byte]]

Extracts body

Extracts body

final def bodyAsString(implicit eb: B <:< Response, ee: E <:< Throwable): Http[R, Throwable, A, String]

Extracts body as a string

Extracts body as a string

final def catchAll[R1 <: R, E1, A1 <: A, B1 >: B](f: E => Http[R1, E1, A1, B1])(implicit ev: CanFail[E]): Http[R1, E1, A1, B1]

Catches all the exceptions that the http app can fail with

Catches all the exceptions that the http app can fail with

final def catchAllDefect[R2 <: R, E2 >: E, A2 <: A, B2 >: B](h: Throwable => Http[R2, E2, A2, B2]): Http[R2, E2, A2, B2]

Recovers from all defects with provided function.

Recovers from all defects with provided function.

'''WARNING''': There is no sensible way to recover from defects. This method should be used only at the boundary between Http and an external system, to transmit information on a defect for diagnostic or explanatory purposes.

final def catchNonFatalOrDie[R2 <: R, E2 >: E, A2 <: A, B2 >: B](h: E => Http[R2, E2, A2, B2])(implicit ev1: CanFail[E], ev2: E <:< Throwable): Http[R2, E2, A2, B2]

Recovers from all NonFatal Throwables.

Recovers from all NonFatal Throwables.

final def catchSome[R1 <: R, E1 >: E, A1 <: A, B1 >: B](f: PartialFunction[E, Http[R1, E1, A1, B1]])(implicit ev: CanFail[E]): Http[R1, E1, A1, B1]

Recovers from some or all of the error cases.

Recovers from some or all of the error cases.

final def catchSomeDefect[R1 <: R, E1 >: E, A1 <: A, B1 >: B](pf: PartialFunction[Throwable, Http[R1, E1, A1, B1]]): Http[R1, E1, A1, B1]

Recovers from some or all of the defects with provided partial function.

Recovers from some or all of the defects with provided partial function.

'''WARNING''': There is no sensible way to recover from defects. This method should be used only at the boundary between Http and an external system, to transmit information on a defect for diagnostic or explanatory purposes.

final def codecMiddleware[R1 <: R, E1 >: E, C, D](other: Http[R1, E1, C, D]): Middleware[R1, E1, B, C, A, D]

Combines two Http instances into a middleware that works a codec for incoming and outgoing messages.

Combines two Http instances into a middleware that works a codec for incoming and outgoing messages.

final def collect[R1 <: R, E1 >: E, A1 <: A, B1 >: B, C](pf: PartialFunction[B1, C]): Http[R1, E1, A1, C]

Collects some of the results of the http and converts it to another type.

Collects some of the results of the http and converts it to another type.

final def collectScoped[R1 <: R, E1 >: E, A1 <: A, B1 >: B, C](pf: PartialFunction[B1, ZIO[Scope & R1, E1, C]]): Http[R1, E1, A1, C]
final def collectZIO[R1 <: R, E1 >: E, A1 <: A, B1 >: B, C](pf: PartialFunction[B1, ZIO[R1, E1, C]]): Http[R1, E1, A1, C]

Collects some of the results of the http and effectfully converts it to another type.

Collects some of the results of the http and effectfully converts it to another type.

final def compose[R1 <: R, E1 >: E, A1 <: A, C1](other: Http[R1, E1, C1, A1]): Http[R1, E1, C1, B]

Named alias for <<<

Named alias for <<<

final def contentLength(implicit eb: B <:< Response): Http[R, E, A, Option[Long]]

Extracts content-length from the response if available

Extracts content-length from the response if available

final def contentType(implicit eb: B <:< Response): Http[R, E, A, Option[CharSequence]]

Extracts the value of ContentType header

Extracts the value of ContentType header

final def contraFlatMap[X]: PartialContraFlatMap[R, E, A, B, X]

Transforms the input of the http before passing it on to the current Http

Transforms the input of the http before passing it on to the current Http

final def contramap[X](xa: X => A): Http[R, E, X, B]

Transforms the input of the http before passing it on to the current Http

Transforms the input of the http before passing it on to the current Http

final def contramapZIO[R1 <: R, E1 >: E, X](xa: X => ZIO[R1, E1, A]): Http[R1, E1, X, B]

Transforms the input of the http before giving it effectfully

Transforms the input of the http before giving it effectfully

final def defaultWith[R1 <: R, E1 >: E, A1 <: A, B1 >: B](other: Http[R1, E1, A1, B1]): Http[R1, E1, A1, B1]

Named alias for ++

Named alias for ++

final def delay(duration: Duration): Http[R, E, A, B]

Delays production of output B for the specified duration of time

Delays production of output B for the specified duration of time

final def delayAfter(duration: Duration): Http[R, E, A, B]

Delays production of output B for the specified duration of time

Delays production of output B for the specified duration of time

final def delayBefore(duration: Duration): Http[R, E, A, B]

Delays consumption of input A for the specified duration of time

Delays consumption of input A for the specified duration of time

final def either(implicit ev: CanFail[E]): Http[R, Nothing, A, Either[E, B]]

Returns an http app whose failure and success have been lifted into an Either. The resulting app cannot fail, because the failure case has been exposed as part of the Either success case.

Returns an http app whose failure and success have been lifted into an Either. The resulting app cannot fail, because the failure case has been exposed as part of the Either success case.

final def flatMap[R1 <: R, E1 >: E, A1 <: A, C1](f: B => Http[R1, E1, A1, C1]): Http[R1, E1, A1, C1]

Creates a new Http app from another

Creates a new Http app from another

final def flatten[R1 <: R, E1 >: E, A1 <: A, B1](implicit ev: B <:< Http[R1, E1, A1, B1]): Http[R1, E1, A1, B1]

Flattens an Http app of an Http app

Flattens an Http app of an Http app

final def foldHttp[R1 <: R, A1 <: A, E1, B1](failure: E => Http[R1, E1, A1, B1], defect: Throwable => Http[R1, E1, A1, B1], success: B => Http[R1, E1, A1, B1], empty: Http[R1, E1, A1, B1]): Http[R1, E1, A1, B1]

Folds over the http app by taking in two functions one for success and one for failure respectively.

Folds over the http app by taking in two functions one for success and one for failure respectively.

final def headerValue(name: CharSequence)(implicit eb: B <:< Response): Http[R, E, A, Option[CharSequence]]

Extracts the value of the provided header name.

Extracts the value of the provided header name.

final def headers(implicit eb: B <:< Response): Http[R, E, A, Headers]

Extracts the Headers from the type B if possible

Extracts the Headers from the type B if possible

final def map[C](bc: B => C): Http[R, E, A, C]

Transforms the output of the http app

Transforms the output of the http app

final def mapError[E1](ee: E => E1): Http[R, E1, A, B]

Transforms the failure of the http app

Transforms the failure of the http app

final def mapZIO[R1 <: R, E1 >: E, C](bFc: B => ZIO[R1, E1, C]): Http[R1, E1, A, C]

Transforms the output of the http effectfully

Transforms the output of the http effectfully

final def merge[E1 >: E, B1 >: B](implicit ev: E1 =:= B1): Http[R, Nothing, A, B1]

Returns a new Http where the error channel has been merged into the success channel to their common combined type.

Returns a new Http where the error channel has been merged into the success channel to their common combined type.

final def middleware[R1 <: R, E1 >: E, A1 <: A, B1 >: B, A2, B2](mid: Middleware[R1, E1, A1, B1, A2, B2]): Http[R1, E1, A2, B2]

Named alias for @@

Named alias for @@

final def narrow[A1](implicit a: A1 <:< A): Http[R, E, A1, B]

Narrows the type of the input

Narrows the type of the input

final def option(implicit ev: CanFail[E]): Http[R, Nothing, A, Option[B]]

Executes this app, skipping the error but returning optionally the success.

Executes this app, skipping the error but returning optionally the success.

final def optional[E1](implicit ev: E <:< Option[E1]): Http[R, E1, A, Option[B]]

Converts an option on errors into an option on values.

Converts an option on errors into an option on values.

final def orDie(implicit ev1: E <:< Throwable, ev2: CanFail[E]): Http[R, Nothing, A, B]

Translates app failure into death of the app, making all failures unchecked and not a part of the type of the app.

Translates app failure into death of the app, making all failures unchecked and not a part of the type of the app.

final def orDieWith(f: E => Throwable)(implicit ev: CanFail[E]): Http[R, Nothing, A, B]

Keeps none of the errors, and terminates the http app with them, using the specified function to convert the E into a Throwable.

Keeps none of the errors, and terminates the http app with them, using the specified function to convert the E into a Throwable.

final def orElse[R1 <: R, E1, A1 <: A, B1 >: B](other: Http[R1, E1, A1, B1]): Http[R1, E1, A1, B1]

Named alias for <>

Named alias for <>

final def provideEnvironment(r: ZEnvironment[R]): Http[Any, E, A, B]

Provides the environment to Http.

Provides the environment to Http.

final def provideLayer[E1 >: E, R0](layer: ZLayer[R0, E1, R]): Http[R0, E1, A, B]

Provides layer to Http.

Provides layer to Http.

final def provideSomeEnvironment[R1](r: ZEnvironment[R1] => ZEnvironment[R]): Http[R1, E, A, B]

Provides some of the environment to Http.

Provides some of the environment to Http.

final def provideSomeLayer[R0, R1, E1 >: E](layer: ZLayer[R0, E1, R1])(implicit ev: R0 & R1 <:< R, tagged: Tag[R1]): Http[R0, E1, A, B]

Provides some of the environment to Http leaving the remainder R0.

Provides some of the environment to Http leaving the remainder R0.

final def race[R1 <: R, E1 >: E, A1 <: A, B1 >: B](other: Http[R1, E1, A1, B1]): Http[R1, E1, A1, B1]

Performs a race between two apps

Performs a race between two apps

final def refineOrDie[E1](pf: PartialFunction[E, E1])(implicit ev1: E <:< Throwable, ev2: CanFail[E]): Http[R, E1, A, B]

Keeps some of the errors, and terminates the http app with the rest.

Keeps some of the errors, and terminates the http app with the rest.

final def refineOrDieWith[E1](pf: PartialFunction[E, E1])(f: E => Throwable)(implicit ev: CanFail[E]): Http[R, E1, A, B]

Keeps some of the errors, and terminates the http app with the rest, using the specified function to convert the E into a Throwable.

Keeps some of the errors, and terminates the http app with the rest, using the specified function to convert the E into a Throwable.

final def status(implicit ev: B <:< Response): Http[R, E, A, Status]

Extracts Status from the type B is possible.

Extracts Status from the type B is possible.

final def tap[R1 <: R, E1 >: E, A1 <: A](f: B => Http[R1, E1, Any, Any]): Http[R1, E1, A, B]

Returns an Http that peeks at the success of this Http.

Returns an Http that peeks at the success of this Http.

final def tapAll[R1 <: R, E1 >: E](failure: E => Http[R1, E1, Any, Any], defect: Throwable => Http[R1, E1, Any, Any], success: B => Http[R1, E1, Any, Any], empty: Http[R1, E1, Any, Any]): Http[R1, E1, A, B]

Returns an Http that peeks at the success, failed, defective or empty value of this Http.

Returns an Http that peeks at the success, failed, defective or empty value of this Http.

final def tapAllZIO[R1 <: R, E1 >: E](failure: E => ZIO[R1, E1, Any], defect: Throwable => ZIO[R1, E1, Any], success: B => ZIO[R1, E1, Any], empty: ZIO[R1, E1, Any]): Http[R1, E1, A, B]

Returns an Http that effectfully peeks at the success, failed, defective or empty value of this Http.

Returns an Http that effectfully peeks at the success, failed, defective or empty value of this Http.

final def tapError[R1 <: R, E1 >: E](f: E => Http[R1, E1, Any, Any]): Http[R1, E1, A, B]

Returns an Http that peeks at the failure of this Http.

Returns an Http that peeks at the failure of this Http.

final def tapErrorZIO[R1 <: R, E1 >: E](f: E => ZIO[R1, E1, Any]): Http[R1, E1, A, B]

Returns an Http that effectfully peeks at the failure of this Http.

Returns an Http that effectfully peeks at the failure of this Http.

final def tapZIO[R1 <: R, E1 >: E](f: B => ZIO[R1, E1, Any]): Http[R1, E1, A, B]

Returns an Http that effectfully peeks at the success of this Http.

Returns an Http that effectfully peeks at the success of this Http.

final def unrefine[E1 >: E](pf: PartialFunction[Throwable, E1]): Http[R, E1, A, B]

Takes some defects and converts them into failures.

Takes some defects and converts them into failures.

final def unrefineTo[E1 >: E : ClassTag]: Http[R, E1, A, B]

Takes some defects and converts them into failures.

Takes some defects and converts them into failures.

final def unrefineWith[E1](pf: PartialFunction[Throwable, E1])(f: E => E1): Http[R, E1, A, B]

Takes some defects and converts them into failures, using the specified function to convert the E into an E1.

Takes some defects and converts them into failures, using the specified function to convert the E into an E1.

final def unwrap[R1 <: R, E1 >: E, C](implicit ev: B <:< ZIO[R1, E1, C]): Http[R1, E1, A, C]

Unwraps an Http that returns a ZIO of Http

Unwraps an Http that returns a ZIO of Http

final def when[A2 <: A](f: A2 => Boolean): Http[R, E, A2, B]

Applies Http based only if the condition function evaluates to true

Applies Http based only if the condition function evaluates to true

final def widen[E1, B1](implicit e: E <:< E1, b: B <:< B1): Http[R, E1, A, B1]

Widens the type of the output

Widens the type of the output

final def zipRight[R1 <: R, E1 >: E, A1 <: A, C1](other: Http[R1, E1, A1, C1]): Http[R1, E1, A1, C1]

Combines the two apps and returns the result of the one on the right

Combines the two apps and returns the result of the one on the right

Inherited methods

def andThen[A](g: ZIO[R, Option[E], B] => A): A => A
Inherited from:
Function1
def compose[A](g: A => A): A => ZIO[R, Option[E], B]
Inherited from:
Function1
override def toString(): String
Definition Classes
Function1 -> Any
Inherited from:
Function1