Middleware

trait Middleware[-R, +E, +AIn, -BIn, -AOut, +BOut]

Middlewares are essentially transformations that one can apply on any Http to produce a new one. They can modify requests and responses and also transform them into more concrete domain entities.

You can think of middlewares as a functions —

 type Middleware[R, E, AIn, BIn, AOut, BOut] = Http[R, E, AIn, BIn] => Http[R, E, AOut, BOut]

The AIn and BIn type params represent the type params of the input Http. The AOut and BOut type params represent the type params of the output Http.

Companion:
object
class Object
trait Matchable
class Any
Middleware[R, E, AIn, BIn, AOut, BOut]

Value members

Abstract methods

def apply[R1 <: R, E1 >: E](http: Http[R1, E1, AIn, BIn]): Http[R1, E1, AOut, BOut]

Applies middleware on Http and returns new Http.

Applies middleware on Http and returns new Http.

Concrete methods

final def ++[R1 <: R, E1 >: E, A0 >: AIn <: AOut, B0 >: BOut <: BIn](other: Middleware[R1, E1, A0, B0, A0, B0]): Middleware[R1, E1, A0, B0, A0, B0]

Combines two middleware that don't modify the input and output types.

Combines two middleware that don't modify the input and output types.

final def <>[R1 <: R, E1, AIn0 >: AIn, BIn0 <: BIn, AOut0 <: AOut, BOut0 >: BOut](other: Middleware[R1, E1, AIn0, BIn0, AOut0, BOut0]): Middleware[R1, E1, AIn0, BIn0, AOut0, BOut0]

Applies self but if it fails, applies other.

Applies self but if it fails, applies other.

final def >>>[R1 <: R, E1 >: E, AIn1 <: AOut, BIn1 >: BOut, AOut1, BOut1](other: Middleware[R1, E1, AIn1, BIn1, AOut1, BOut1]): Middleware[R1, E1, AIn, BIn, AOut1, BOut1]

Creates a new middleware that passes the output Http of the current middleware as the input to the provided middleware.

Creates a new middleware that passes the output Http of the current middleware as the input to the provided middleware.

final def andThen[R1 <: R, E1 >: E, AIn1 <: AOut, BIn1 >: BOut, AOut1, BOut1](other: Middleware[R1, E1, AIn1, BIn1, AOut1, BOut1]): Middleware[R1, E1, AIn, BIn, AOut1, BOut1]

Composes one middleware with another.

Composes one middleware with another.

final def as[BOut0](bout: BOut0): Middleware[R, E, AIn, BIn, AOut, BOut0]

Makes the middleware resolve with a constant Middleware

Makes the middleware resolve with a constant Middleware

final def combine[R1 <: R, E1 >: E, A0 >: AIn <: AOut, B0 >: BOut <: BIn](other: Middleware[R1, E1, A0, B0, A0, B0]): Middleware[R1, E1, A0, B0, A0, B0]

Combines two middleware that operate on the same input and output types, into one.

Combines two middleware that operate on the same input and output types, into one.

final def contramap[AOut0](f: AOut0 => AOut): Middleware[R, E, AIn, BIn, AOut0, BOut]

Preprocesses the incoming value for the outgoing Http.

Preprocesses the incoming value for the outgoing Http.

final def contramapZIO[AOut0]: PartialContraMapZIO[R, E, AIn, BIn, AOut, BOut, AOut0]

Preprocesses the incoming value using a ZIO, for the outgoing Http.

Preprocesses the incoming value using a ZIO, for the outgoing Http.

final def delay(duration: Duration): Middleware[R & Clock, E, AIn, BIn, AOut, BOut]

Delays the production of Http output for the specified duration

Delays the production of Http output for the specified duration

final def flatMap[R1 <: R, E1 >: E, AIn0 >: AIn, BIn0 <: BIn, AOut0 <: AOut, BOut0](f: BOut => Middleware[R1, E1, AIn0, BIn0, AOut0, BOut0]): Middleware[R1, E1, AIn0, BIn0, AOut0, BOut0]

Creates a new Middleware from another

Creates a new Middleware from another

final def flatten[R1 <: R, E1 >: E, AIn0 >: AIn, BIn0 <: BIn, AOut0 <: AOut, BOut0](implicit ev: BOut <:< Middleware[R1, E1, AIn0, BIn0, AOut0, BOut0]): Middleware[R1, E1, AIn0, BIn0, AOut0, BOut0]

Flattens an Middleware of a Middleware

Flattens an Middleware of a Middleware

final def map[BOut0](f: BOut => BOut0): Middleware[R, E, AIn, BIn, AOut, BOut0]

Transforms the output type of the current middleware.

Transforms the output type of the current middleware.

final def mapZIO[R1 <: R, E1 >: E, BOut0](f: BOut => ZIO[R1, E1, BOut0]): Middleware[R1, E1, AIn, BIn, AOut, BOut0]

Transforms the output type of the current middleware using effect function.

Transforms the output type of the current middleware using effect function.

final def orElse[R1 <: R, E1, AIn0 >: AIn, BIn0 <: BIn, AOut0 <: AOut, BOut0 >: BOut](other: Middleware[R1, E1, AIn0, BIn0, AOut0, BOut0]): Middleware[R1, E1, AIn0, BIn0, AOut0, BOut0]

Applies self but if it fails, applies other.

Applies self but if it fails, applies other.

final def race[R1 <: R, E1 >: E, AIn1 >: AIn, BIn1 <: BIn, AOut1 <: AOut, BOut1 >: BOut](other: Middleware[R1, E1, AIn1, BIn1, AOut1, BOut1]): Middleware[R1, E1, AIn1, BIn1, AOut1, BOut1]

Race between current and other, cancels other when execution of one completes

Race between current and other, cancels other when execution of one completes

final def runAfter[R1 <: R, E1 >: E](effect: ZIO[R1, E1, Any]): Middleware[R1, E1, AIn, BIn, AOut, BOut]
final def runBefore[R1 <: R, E1 >: E](effect: ZIO[R1, E1, Any]): Middleware[R1, E1, AIn, BIn, AOut, BOut]
final def when[AOut0 <: AOut](cond: AOut0 => Boolean)(implicit ev: IsMono[AIn, BIn, AOut0, BOut]): Middleware[R, E, AIn, BIn, AOut0, BOut]

Applies Middleware based only if the condition function evaluates to true

Applies Middleware based only if the condition function evaluates to true

final def whenZIO[R1 <: R, E1 >: E, AOut0 <: AOut](cond: AOut0 => ZIO[R1, E1, Boolean])(implicit ev: IsMono[AIn, BIn, AOut0, BOut]): Middleware[R1, E1, AIn, BIn, AOut0, BOut]

Applies Middleware based only if the condition effectful function evaluates to true

Applies Middleware based only if the condition effectful function evaluates to true