abstract class Router[Input, +Route] extends (Input) ⇒ Result with ClosableOnce with Logging
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
Routemay have dynamic properties and may be found to satisfy multipleInputinstances. As there may not be a 1-to-1 mapping ofInputtoRoute, it is encouraged that aRouteencapsulates 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, theRoutein this example should be aware of the method, path, and and the destination/logic responsible for handling anInputthat matches. Another property to consider for aRouteis "uniqueness". A Router should be able to determine either: a) a singleRoutefor anInputb) noRoutefor anInputA Router should NOT be expected to return multiple routes for anInput.
- Note
A Router should be considered immutable unless explicitly noted.
- Alphabetic
- By Inheritance
- Router
- Logging
- ClosableOnce
- CloseOnce
- Closable
- Function1
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
-
new
Router(label: String, routes: Iterable[Route])
Java-friendly constructor
-
new
Router(label: String, routes: Iterable[Route])
- label
A label used for identifying this Router (i.e. for distinguishing between Router instances in error messages or for StatsReceiver scope).
- routes
All of the
Routeroutes contained within this Router This property is used to linearly determine the routes whenclose()is called. It may also be used as a way to determine what routes are defined within a Router (i.e. for generating meaningful error messages). This property does not imply any relationship with apply or find or that a Router's runtime behavior needs to be linear.
Abstract Value Members
-
abstract
def
find(input: Input): Result
Logic used to determine if this Router contains a
Routefor anInput.Logic used to determine if this Router contains a
Routefor anInput.- input
The
Inputto determine a route for.- returns
Found(input: Input, route: Route)if a matching route is defined, NotFound if a route destination is not defined for theInput.
- Attributes
- protected
- Note
This method is only meant to be called within the Router's
apply, which handles lifecycle concerns. It should not be accessed directly.
Concrete Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
andThen[A](g: (Result) ⇒ A): (Input) ⇒ A
- Definition Classes
- Function1
- Annotations
- @unspecialized()
-
final
def
apply(input: Input): Result
Attempt to route an
Inputto aRouteroute known by this Router.Attempt to route an
Inputto aRouteroute known by this Router.- input
The
Inputto use for determining an available route- returns
Found(input: Input, route: Route)if a route is found to match, NotFound if there is no match, or RouterClosed ifclose()has been initiated on this Router and subsequent routing attempts are received.
- Definition Classes
- Router → Function1
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
final
def
close(deadline: Time): Future[Unit]
- Definition Classes
- CloseOnce → Closable
-
def
close(after: Duration): Future[Unit]
- Definition Classes
- Closable
-
final
def
close(): Future[Unit]
- Definition Classes
- Closable
-
final
def
closeFuture: Future[Unit]
- Attributes
- protected
- Definition Classes
- CloseOnce
-
def
closeOnce(deadline: Time): Future[Unit]
- Attributes
- protected
- Definition Classes
- Router → CloseOnce
- Note
NonFatal exceptions encountered when calling
close()on aRoutewill be suppressed and Fatal exceptions will take on the same exception behavior of aFuture.join.
-
def
compose[A](g: (A) ⇒ Input): (A) ⇒ Result
- Definition Classes
- Function1
- Annotations
- @unspecialized()
-
def
debug(marker: Marker, message: ⇒ Any, cause: Throwable): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
debug(message: ⇒ Any, cause: Throwable): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
debug(marker: Marker, message: ⇒ Any): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
debug(message: ⇒ Any): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
debugResult[T](message: ⇒ String)(fn: ⇒ T): T
- Attributes
- protected[this]
- Definition Classes
- Logging
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
error(marker: Marker, message: ⇒ Any, cause: Throwable): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
error(message: ⇒ Any, cause: Throwable): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
error(marker: Marker, message: ⇒ Any): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
error(message: ⇒ Any): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
errorResult[T](message: ⇒ String)(fn: ⇒ T): T
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
info(marker: Marker, message: ⇒ Any, cause: Throwable): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
info(message: ⇒ Any, cause: Throwable): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
info(marker: Marker, message: ⇒ Any): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
info(message: ⇒ Any): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
infoResult[T](message: ⇒ String)(fn: ⇒ T): T
- Attributes
- protected[this]
- Definition Classes
- Logging
-
final
def
isClosed: Boolean
- Definition Classes
- CloseOnce
-
def
isDebugEnabled(marker: Marker): Boolean
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
isDebugEnabled: Boolean
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
isErrorEnabled(marker: Marker): Boolean
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
isErrorEnabled: Boolean
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
isInfoEnabled(marker: Marker): Boolean
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
isInfoEnabled: Boolean
- Attributes
- protected[this]
- Definition Classes
- Logging
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
isTraceEnabled(marker: Marker): Boolean
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
isTraceEnabled: Boolean
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
isWarnEnabled(marker: Marker): Boolean
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
isWarnEnabled: Boolean
- Attributes
- protected[this]
- Definition Classes
- Logging
- val label: String
-
final
def
logger: Logger
- Attributes
- protected[this]
- Definition Classes
- Logging
-
final
def
loggerName: String
- Attributes
- protected[this]
- Definition Classes
- Logging
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- val routes: Iterable[Route]
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- Function1 → AnyRef → Any
-
def
trace(marker: Marker, message: ⇒ Any, cause: Throwable): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
trace(message: ⇒ Any, cause: Throwable): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
trace(marker: Marker, message: ⇒ Any): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
trace(message: ⇒ Any): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
traceResult[T](message: ⇒ String)(fn: ⇒ T): T
- Attributes
- protected[this]
- Definition Classes
- Logging
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
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()
-
def
warn(marker: Marker, message: ⇒ Any, cause: Throwable): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
warn(message: ⇒ Any, cause: Throwable): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
warn(marker: Marker, message: ⇒ Any): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
warn(message: ⇒ Any): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
warnResult[T](message: ⇒ String)(fn: ⇒ T): T
- Attributes
- protected[this]
- Definition Classes
- Logging