final case class HandlerAspect[-Env, +CtxOut](protocol: ProtocolStack[Env, Request, (Request, CtxOut), Response, Response]) extends Middleware[Env] with Product with Serializable
A zio.http.HandlerAspect is a kind of zio.http.ProtocolStack that is specialized to transform a handler's incoming requests and outgoing responses. Each layer in the stack corresponds to a separate transformation.
Layers may incorporate layer-specific information into a generic type parameter, referred to as middleware context, which composes using tupling.
Layers may also be stateful at the level of each transformation application. So, for example, a layer that is timing request durations may capture the start time of the request in the incoming interceptor, and pass this state to the outgoing interceptor, which can then compute the duration.
zio.http.HandlerAspect is more than just a wrapper around zio.http.ProtocolStack, as its concatenation operator has been specialized to entuple contexts, so that each layer may only add context to the contextual output.
- Self Type
- HandlerAspect[Env, CtxOut]
- Alphabetic
- By Inheritance
- HandlerAspect
- Serializable
- Product
- Equals
- Middleware
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- def ++[Env1 <: Env, CtxOut2](that: HandlerAspect[Env1, CtxOut2])(implicit zippable: Zippable[CtxOut, CtxOut2]): HandlerAspect[Env1, Out]
Combines this middleware with the specified middleware sequentially, such that this middleware will be applied first on incoming requests, and last on outgoing responses, and the specified middleware will be applied last on incoming requests, and first on outgoing responses.
Combines this middleware with the specified middleware sequentially, such that this middleware will be applied first on incoming requests, and last on outgoing responses, and the specified middleware will be applied last on incoming requests, and first on outgoing responses. Context from both middleware will be combined using tuples.
- def ++[UpperEnv1 <: Env](that: Middleware[UpperEnv1]): Middleware[UpperEnv1]
- Definition Classes
- Middleware
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def @@[UpperEnv1 <: Env](that: Middleware[UpperEnv1]): Middleware[UpperEnv1]
- Definition Classes
- Middleware
- def apply[Env1 <: Env, Err](routes: Routes[Env1, Err]): Routes[Env1, Err]
Applies middleware to the specified handler, which may ignore the context produced by this middleware.
Applies middleware to the specified handler, which may ignore the context produced by this middleware.
- Definition Classes
- HandlerAspect → Middleware
- def applyHandler[Env1 <: Env](handler: RequestHandler[Env1, Response]): RequestHandler[Env1, Response]
- def applyHandlerContext[Env1 <: Env](handler: Handler[Env1, Response, (CtxOut, Request), Response]): Handler[Env1, Response, Request, Response]
Applies middleware to the specified handler, which must process the context produced by this middleware.
- def as[CtxOut2](ctxOut2: => CtxOut2): HandlerAspect[Env, CtxOut2]
Returns new middleware that transforms the context of the middleware to the specified constant.
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native() @IntrinsicCandidate()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @IntrinsicCandidate()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def map[CtxOut2](f: (CtxOut) => CtxOut2): HandlerAspect[Env, CtxOut2]
Returns new middleware that transforms the context of the middleware using the specified function.
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @IntrinsicCandidate()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @IntrinsicCandidate()
- def productElementNames: Iterator[String]
- Definition Classes
- Product
- val protocol: ProtocolStack[Env, Request, (Request, CtxOut), Response, Response]
- def provideEnvironment(env: ZEnvironment[Env]): HandlerAspect[Any, CtxOut]
Returns new middleware that fully provides the specified environment to this middleware, resulting in middleware that has no contextual dependencies.
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def unit: HandlerAspect[Env, Unit]
Returns new middleware that produces the unit value as its context.
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- def when(condition: (Request) => Boolean): HandlerAspect[Env, Unit]
Conditionally applies this middleware to the specified handler, based on the result of the predicate applied to the incoming request.
- def whenHeader(condition: (Headers) => Boolean): HandlerAspect[Env, Unit]
Conditionally applies this middleware to the specified handler, based on the result of the predicate applied to the incoming request's headers.
- def whenZIO[Env1 <: Env](condition: (Request) => ZIO[Env1, Response, Boolean]): HandlerAspect[Env1, Unit]
Conditionally applies this middleware to the specified handler, based on the result of the effectful predicate applied to the incoming request.