T - The target endpoint type.public final class Router<T> extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
Router.Builder<T>
Router builder.
|
static class |
Router.Result<T>
Routing result holder.
|
static class |
Router.Status
Routing result.
|
| Modifier and Type | Method and Description |
|---|---|
static <T> Router.Builder<T> |
builder() |
static <T> Router.Builder<T> |
builder(Class<T> clazz) |
Router.Result<T> |
result()
Create a
Router.Result with enough capacity to hold all captured parameters for any endpoint
of this router. |
Router.Status |
route(CharSequence method,
CharSequence path,
Router.Result<T> result)
Route a request.
|
public static <T> Router.Builder<T> builder()
public static <T> Router.Builder<T> builder(Class<T> clazz)
public Router.Status route(CharSequence method, CharSequence path, Router.Result<T> result)
method - The request method. E.g. GET, PUT, POST, DELETE, etc.path - The request path. E.g. /foo/baz/bar.result - A Router.Result for storing the routing result, target and captured parameters.
The Router.Result should have enough capacity to store all captured parameters.
See result().Router.Status.SUCCESS if an endpoint and matching method was found.
Router.Status.NOT_FOUND if the endpoint could not be found, Router.Status.METHOD_NOT_ALLOWED
if the endpoint was found but the method did not match.public Router.Result<T> result()
Router.Result with enough capacity to hold all captured parameters for any endpoint
of this router. The Router.Result is intended to be instantiated reused, to avoid garbage.
Note that the Router.Result is not thread safe, so a dedicated Router.Result should be
created per thread.Copyright © 2015. All Rights Reserved.