final class Routes[-Env, +Err] extends AnyRef
Represents a collection of routes, each of which is defined by a pattern and a handler. This data type can be thought of as modeling a routing table, which decides where to direct every endpoint in an API based on both method and path of the request.
When you are done building a collection of routes, you typically convert the
routes into an zio.http.HttpApp value, which can be done with the
toHttpApp method.
Routes may have handled or unhandled errors. A route of type Route[Env,
Throwable], for example, has not handled its errors by converting them into
responses. Such unfinished routes cannot yet be converted into
zio.http.HttpApp values. First, you must handle errors with the
handleError or handleErrorCause methods.
- Self Type
- Routes[Env, Err]
- Alphabetic
- By Inheritance
- Routes
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
def
++[Env1 <: Env, Err1 >: Err](that: Routes[Env1, Err1]): Routes[Env1, Err1]
Returns the concatenation of these routes with the specified routes.
-
def
+:[Env1 <: Env, Err1 >: Err](route: Route[Env1, Err1]): Routes[Env1, Err1]
Prepends the specified route to this collection of routes.
-
def
:+[Env1 <: Env, Err1 >: Err](route: Route[Env1, Err1]): Routes[Env1, Err1]
Appends the specified route to this collection of routes.
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def @@[Env1 <: Env](aspect: Middleware[Env1]): Routes[Env1, Err]
- def apply(request: Request)(implicit ev: <:<[Err, Response], trace: Trace): ZIO[Env, Response, Response]
- def asEnvType[Env2](implicit ev: <:<[Env2, Env]): Routes[Env2, Err]
- def asErrorType[Err2](implicit ev: <:<[Err, Err2]): Routes[Env, Err2]
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native() @IntrinsicCandidate()
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @IntrinsicCandidate()
-
def
handleError(f: (Err) ⇒ Response)(implicit trace: Trace): Routes[Env, Nothing]
Handles all typed errors in the routes by converting them into responses.
Handles all typed errors in the routes by converting them into responses. This method can be used to convert routes that do not handle their errors into ones that do handle their errors.
-
def
handleErrorCause(f: (Cause[Err]) ⇒ Response)(implicit trace: Trace): Routes[Env, Nothing]
Handles all typed errors, as well as all non-recoverable errors, by converting them into responses.
Handles all typed errors, as well as all non-recoverable errors, by converting them into responses. This method can be used to convert routes that do not handle their errors into ones that do handle their errors.
-
def
handleErrorCauseZIO(f: (Cause[Err]) ⇒ ZIO[Any, Nothing, Response])(implicit trace: Trace): Routes[Env, Nothing]
Handles all typed errors, as well as all non-recoverable errors, by converting them into a ZIO effect that produces the response.
Handles all typed errors, as well as all non-recoverable errors, by converting them into a ZIO effect that produces the response. This method can be used to convert routes that do not handle their errors into ones that do handle their errors.
-
def
handleErrorRequest(f: (Err, Request) ⇒ Response)(implicit trace: Trace): Routes[Env, Nothing]
Handles all typed errors in the routes by converting them into responses, taking into account the request that caused the error.
Handles all typed errors in the routes by converting them into responses, taking into account the request that caused the error. This method can be used to convert routes that do not handle their errors into ones that do handle their errors.
-
def
handleErrorRequestCause(f: (Request, Cause[Err]) ⇒ Response)(implicit trace: Trace): Routes[Env, Nothing]
Handles all typed errors in the routes by converting them into responses, taking into account the request that caused the error.
Handles all typed errors in the routes by converting them into responses, taking into account the request that caused the error. This method can be used to convert routes that do not handle their errors into ones that do handle their errors.
-
def
handleErrorRequestCauseZIO(f: (Request, Cause[Err]) ⇒ ZIO[Any, Nothing, Response])(implicit trace: Trace): Routes[Env, Nothing]
Handles all typed errors, as well as all non-recoverable errors, by converting them into a ZIO effect that produces the response, taking into account the request that caused the error.
Handles all typed errors, as well as all non-recoverable errors, by converting them into a ZIO effect that produces the response, taking into account the request that caused the error. This method can be used to convert routes that do not handle their errors into ones that do handle their errors.
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @IntrinsicCandidate()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
mapError[Err1](fxn: (Err) ⇒ Err1): Routes[Env, Err1]
Allows the transformation of the Err type through a function allowing one to build up a Routes in Stages delegates to the Route
-
def
mapErrorZIO[Err1](fxn: (Err) ⇒ ZIO[Any, Err1, Response])(implicit trace: Trace): Routes[Env, Err1]
Allows the transformation of the Err type through an Effectful program allowing one to build up a Routes in Stages delegates to the Route
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def nest(prefix: PathCodec[Unit])(implicit trace: Trace, ev: <:<[Err, Response]): Routes[Env, Err]
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @IntrinsicCandidate()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @IntrinsicCandidate()
-
def
provideEnvironment(env: ZEnvironment[Env]): Routes[Any, Err]
Returns new routes that have each been provided the specified environment, thus eliminating their requirement for any specific environment.
- val routes: Chunk[Route[Env, Err]]
- def run(request: Request)(implicit trace: Trace): ZIO[Env, Either[Err, Response], Response]
-
def
sandbox(implicit trace: Trace): Routes[Env, Nothing]
Returns new routes that automatically translate all failures into responses, using best-effort heuristics to determine the appropriate HTTP status code, and attaching error details using the HTTP header
Warning. -
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
timeout(duration: zio.Duration)(implicit trace: Trace): Routes[Env, Err]
Returns new routes that are all timed out by the specified maximum duration.
-
def
toHttpApp(implicit ev: <:<[Err, Response]): HttpApp[Env]
Converts the routes into an app, which can be done only when errors are handled and converted into responses.
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
def
transform[Env1](f: (Handler[Env, Response, Request, Response]) ⇒ Handler[Env1, Response, Request, Response]): Routes[Env1, Err]
Returns new routes whose handlers are transformed by the specified function.
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )