RoutePattern

zio.http.RoutePattern
See theRoutePattern companion object
final case class RoutePattern[A](method: Method, pathCodec: PathCodec[A])

A pattern for matching routes that examines both HTTP method and path. In addition to specifying a method, patterns contain segment patterns, which are sequences of literals, integers, longs, and other segment types.

Typically, your entry point constructor for a route pattern would be zio.http.Method:

import zio.http.Method
import zio.http.codec.SegmentCodec._

val pattern = Method.GET / "users" / int("user-id") / "posts" / string("post-id")

However, you can use the convenience constructors in RoutePattern, such as RoutePattern.GET.

Attributes

Companion
object
Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
Self type

Members list

Value members

Concrete methods

def ->[Env, Err, I](handler: Handler[Env, Err, I, Response])(implicit zippable: RequestHandlerInput[A, I], trace: Trace): Route[Env, Err]

Creates a route from this pattern and the specified handler.

Creates a route from this pattern and the specified handler.

Attributes

def ->[Env, Err](handler: Handler[Env, Response, Request, Response])(implicit trace: Trace): Route[Env, Err]

Creates a route from this pattern and the specified handler, which ignores any parameters produced by this route pattern. This method exists for performance reasons, as it avoids all overhead of propagating parameters or supporting contextual middleware.

Creates a route from this pattern and the specified handler, which ignores any parameters produced by this route pattern. This method exists for performance reasons, as it avoids all overhead of propagating parameters or supporting contextual middleware.

Attributes

def ->[Env, Context](middleware: HandlerAspect[Env, Context])(implicit zippable: Zippable[A, Context]): Builder[Env, Out]

Combines this route pattern with the specified middleware, which can be used to build a route by providing a handler.

Combines this route pattern with the specified middleware, which can be used to build a route by providing a handler.

Attributes

def /[B](that: PathCodec[B])(implicit combiner: Combiner[A, B]): RoutePattern[Out]

Returns a new pattern that is extended with the specified segment pattern.

Returns a new pattern that is extended with the specified segment pattern.

Attributes

def ??(doc: Doc): RoutePattern[A]

Attaches documentation to the route pattern, which may be used when generating developer docs for a route.

Attaches documentation to the route pattern, which may be used when generating developer docs for a route.

Attributes

def asType[B](implicit ev: A =:= B): RoutePattern[B]

Reinteprets the type parameter, given evidence it is equal to some other type.

Reinteprets the type parameter, given evidence it is equal to some other type.

Attributes

def decode(actual: Method, path: Path): Either[String, A]

Decodes a method and path into a value of type A.

Decodes a method and path into a value of type A.

Attributes

def doc: Doc

Returns the documentation for the route pattern, if any.

Returns the documentation for the route pattern, if any.

Attributes

def encode(value: A): Either[String, (Method, Path)]

Encodes a value of type A into the method and path that this route pattern would successfully match against.

Encodes a value of type A into the method and path that this route pattern would successfully match against.

Attributes

def format(value: A): Either[String, Path]

Formats a value of type A into a path. This is useful for embedding paths into HTML that is rendered by the server.

Formats a value of type A into a path. This is useful for embedding paths into HTML that is rendered by the server.

Attributes

def matches(method: Method, path: Path): Boolean

Determines if this pattern matches the specified method and path. Rather than use this method, you should just try to decode it directly, for higher performance, otherwise the same information will be decoded twice.

Determines if this pattern matches the specified method and path. Rather than use this method, you should just try to decode it directly, for higher performance, otherwise the same information will be decoded twice.

Attributes

def nest(prefix: PathCodec[Unit]): RoutePattern[A]
def render: String

Renders the route pattern as a string.

Renders the route pattern as a string.

Attributes

Converts the route pattern into an HttpCodec that produces the same value.

Converts the route pattern into an HttpCodec that produces the same value.

Attributes

override def toString(): String

Returns a string representation of the object.

Returns a string representation of the object.

The default representation is platform dependent.

Attributes

Returns

a string representation of the object.

Definition Classes
Any
def unapply(tuple: (Method, Path)): Option[A]

This exists for use with Scala custom extractor syntax, allowing route patterns to match against and deconstruct tuples of methods and paths.

This exists for use with Scala custom extractor syntax, allowing route patterns to match against and deconstruct tuples of methods and paths.

Attributes

Inherited methods

def productElementNames: Iterator[String]

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

Attributes

Inherited from:
Product