package routing
- Alphabetic
- Public
- Protected
Type Members
- case class ClosedRouterException(router: Router[_, _]) extends RuntimeException with NoStackTrace with Product with Serializable
Exception thrown when an attempt to route an
Input
to a Router whereclose
has been initiated on the Router. - final case class Found[Input, Route](input: Input, route: Route) extends Result with Product with Serializable
A result that represents that the router could determine a defined route for a given input.
- abstract class Generator[Input, Route, +RouterType <: Router[Input, Route]] extends (RouterInfo[Route]) => RouterType
Functional alias for creating a router given a label and all of the defined routes for the router to be generated.
- sealed abstract class Result extends AnyRef
A result from attempting to find a route via a Router.
- abstract class Router[Input, +Route] extends (Input) => Result with ClosableOnce with Logging
A generic interface for routing an input to an optional matching route.
A generic interface for routing an input to an optional matching route.
- Input
The Input type used when determining a route destination
- Route
The resulting route type. A
Route
may have dynamic properties and may be found to satisfy multipleInput
instances. As there may not be a 1-to-1 mapping ofInput
toRoute
, it is encouraged that aRoute
encapsulates its relationship to anInput
. An example to consider would be an HTTP Router. An HTTP request contains a Method (i.e. GET, POST) and a URI. A Router for a REST API may match "GET /users/{id}" for multiple HTTP requests (i.e. "GET /users/123" AND "GET /users/456" would map to the same destinationRoute
). As a result, theRoute
in this example should be aware of the method, path, and and the destination/logic responsible for handling anInput
that matches. Another property to consider for aRoute
is "uniqueness". A Router should be able to determine either: a) a singleRoute
for anInput
b) noRoute
for anInput
A Router should NOT be expected to return multiple routes for anInput
.
- Note
A Router should be considered immutable unless explicitly noted.
- case class RouterBuilder[Input, Route, +RouterType <: Router[Input, Route]] extends Product with Serializable
Utility for building and creating routers.
Utility for building and creating routers. The resulting router should be considered immutable, unless the router's implementation explicitly states otherwise.
- Input
The router's
Input
type.- Route
The router's destination
Route
type. It is recommended that theRoute
is a self-contained/self-describing type for the purpose of validation via the Validator. Put differently, theRoute
should know of theInput
that maps to itself.- RouterType
The type of Router to build.
- case class RouterInfo[+Route](label: String, routes: Iterable[Route]) extends Product with Serializable
The information needed to generate a Router via a Generator.
- case class ValidationError(msg: String) extends Product with Serializable
Container class for an error that is encountered as part of validating routes via a RouterBuilder.
Container class for an error that is encountered as part of validating routes via a RouterBuilder.
- msg
The message that explains the error.
- case class ValidationException extends Exception with Product with Serializable
Exception thrown when a RouterBuilder observes any routes that are not valid for the Router type it is building.
- abstract class Validator[-Route] extends (Iterable[Route]) => Iterable[ValidationError]
Functional alias for determining whether all defined results are valid for a specific router type.
Value Members
- case object NotFound extends Result with Product with Serializable
A result that represents that the router could not determine a defined route for a given input.
- object RouterBuilder extends Serializable
- case object RouterClosed extends Result with Product with Serializable
A result that represents that the router has been closed and will no longer attempt to find routes for any inputs.
- object Validator