Routes

zio.http.Routes
See theRoutes companion object
final case class Routes[-Env, +Err](routes: Chunk[Route[Env, Err]])

An HTTP application is a collection of routes, all of whose errors have been handled through conversion into HTTP responses.

HTTP applications can be installed into a zio.http.Server, which is capable of using them to serve requests.

Attributes

Companion
object
Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
Self type
Routes[Env, Err]

Members list

Value members

Concrete methods

def ++[Env1 <: Env, Err1 >: Err](that: Routes[Env1, Err1]): Routes[Env1, Err1]

Combines this Routes with the specified Routes. In case of route conflicts, the new Routes take precedence over the current Routes.

Combines this Routes with the specified Routes. In case of route conflicts, the new Routes take precedence over the current Routes.

Attributes

def +:[Env1 <: Env, Err1 >: Err](route: Route[Env1, Err1]): Routes[Env1, Err1]

Prepend the specified route.

Prepend the specified route.

Attributes

def :+[Env1 <: Env, Err1 >: Err](route: Route[Env1, Err1]): Routes[Env1, Err1]

Appends the specified route.

Appends the specified route.

Attributes

def @@[Env1 <: Env](aspect: Middleware[Env1]): Routes[Env1, Err]
def @@[Env0](aspect: HandlerAspect[Env0, Unit]): Routes[Env & Env0, Err]
def @@[Env0, Ctx <: Env](aspect: HandlerAspect[Env0, Ctx])(implicit tag: Tag[Ctx]): Routes[Env0, Err]
def @@[Env0]: ApplyContextAspect[Env, Err, Env0]
def apply(request: Request)(implicit ev: Err <:< Response): ZIO[Scope & Env, Response, Response]

Executes the HTTP application with the specified request input, returning an effect that will either succeed or fail with a Response.

Executes the HTTP application with the specified request input, returning an effect that will either succeed or fail with a Response.

Attributes

def handleError(f: Err => Response)(implicit trace: Trace): Routes[Env, Nothing]

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.

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.

Attributes

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. This method can be used to convert routes that do not handle their errors into ones that do handle their errors.

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.

Attributes

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. This method can be used to convert routes that do not handle their errors into ones that do handle their errors.

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.

Attributes

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. This method can be used to convert routes that do not handle their errors into ones that do handle their errors.

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.

Attributes

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. This method can be used to convert routes that do not handle their errors into ones that do handle their errors.

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.

Attributes

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. This method can be used to convert routes that do not handle their errors into ones that do handle their errors.

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.

Attributes

def handleErrorZIO[Env1 <: Env](f: Err => ZIO[Env1, Nothing, Response])(implicit trace: Trace): Routes[Env1, Nothing]
def isDefinedAt(request: Request)(implicit ev: Err <:< Response): Boolean

Checks to see if the HTTP application may be defined at the specified request input. Note that it is still possible for an HTTP application to return a 404 Not Found response, which cannot be detected by this method. This method only checks for the presence of a handler that handles the method and path of the specified request.

Checks to see if the HTTP application may be defined at the specified request input. Note that it is still possible for an HTTP application to return a 404 Not Found response, which cannot be detected by this method. This method only checks for the presence of a handler that handles the method and path of the specified request.

Attributes

def mapError[Err1](fxn: Err => Err1): Routes[Env, Err1]

Allows the transformation of the Err type through a function allowing one to build up Routes in Stages delegates to the Route.

Allows the transformation of the Err type through a function allowing one to build up Routes in Stages delegates to the Route.

Attributes

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 Routes in Stages delegates to the Route.

Allows the transformation of the Err type through an Effectful program allowing one to build up Routes in Stages delegates to the Route.

Attributes

def nest(prefix: PathCodec[Unit])(implicit trace: Trace): Routes[Env, Err]
def provide[Env1 <: Env](env: Env1)(implicit tag: Tag[Env1]): Routes[Any, Err]
def provideEnvironment(env: ZEnvironment[Env]): Routes[Any, Err]

Provides the specified environment to the HTTP application, returning a new HTTP application that has no environmental requirements.

Provides the specified environment to the HTTP application, returning a new HTTP application that has no environmental requirements.

Attributes

def run(request: Request)(implicit trace: Trace): ZIO[Scope & Env, Either[Err, Response], Response]
def run(method: Method = ..., path: Path = ..., headers: Headers = ..., body: Body = ...)(implicit ev: Err <:< Response): ZIO[Scope & Env, Nothing, Response]
def runZIO(request: Request)(implicit ev: Err <:< Response): ZIO[Scope & Env, Nothing, Response]

An alias for apply.

An alias for apply.

Attributes

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.

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.

Attributes

def serve[Env1 <: Env](implicit ev: Err <:< Response, trace: Trace, tag: Tag[Env1]): URIO[Env1 & Server, Nothing]

A shortcut for Server.install(routes) *> ZIO.never

A shortcut for Server.install(routes) *> ZIO.never

Attributes

def tapErrorCauseZIO[Err1 >: Err](f: (Cause[Err]) => ZIO[Any, Err1, Any])(implicit trace: Trace): Routes[Env, Err1]

Effectfully peeks at the unhandled failure cause of this Routes.

Effectfully peeks at the unhandled failure cause of this Routes.

Attributes

def tapErrorZIO[Err1 >: Err](f: Err => ZIO[Any, Err1, Any])(implicit trace: Trace): Routes[Env, Err1]

Effectfully peeks at the unhandled failure of this Routes.

Effectfully peeks at the unhandled failure of this Routes.

Attributes

def timeout(duration: Duration)(implicit trace: Trace): Routes[Env, Err]

Returns a new HTTP application whose requests will be timed out after the specified duration elapses.

Returns a new HTTP application whose requests will be timed out after the specified duration elapses.

Attributes

def toHandler(implicit ev: Err <:< Response): Handler[Env, Nothing, Request, Response]

Converts the HTTP application into a request handler.

Converts the HTTP application into a request handler.

Attributes

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.

Returns new Routes whose handlers are transformed by the specified function.

Attributes

def tree[Env1 <: Env](implicit trace: Trace, ev: Err <:< Response): Tree[Env1]

Accesses the underlying tree that provides fast dispatch to handlers.

Accesses the underlying tree that provides fast dispatch to handlers.

Attributes

Inherited methods

Attributes

Inherited from:
Product

Attributes

Inherited from:
Product

Concrete fields

var notFound: Handler[Any, Nothing, Request, Response]