public static interface Route.Chain
Modifier and Type | Method and Description |
---|---|
default void |
next(Request req,
Response rsp)
Invokes the next route in the chain.
|
void |
next(String prefix,
Request req,
Response rsp)
Invokes the next route in the chain where
Route.name() starts with the given prefix. |
List<Route> |
routes()
All the pending/next routes from pipeline.
|
void next(@Nullable String prefix, Request req, Response rsp) throws Throwable
Route.name()
starts with the given prefix.prefix
- Iterates over the route chain and keep routes that start with the given prefix.req
- A HTTP request.rsp
- A HTTP response.Throwable
- If invocation goes wrong.default void next(Request req, Response rsp) throws Throwable
req
- A HTTP request.rsp
- A HTTP response.Throwable
- If invocation goes wrong.List<Route> routes()
use("*", (req, rsp, chain) -> {
List<Route> routes = chain.routes();
assertEquals(2, routes.size());
assertEquals("/r2", routes.get(0).name());
assertEquals("/r3", routes.get(1).name());
assertEquals("/786/:id", routes.get(routes.size() - 1).pattern());
chain.next(req, rsp);
}).name("r1");
use("/786/**", (req, rsp, chain) -> {
List<Route> routes = chain.routes();
assertEquals(1, routes.size());
assertEquals("/r3", routes.get(0).name());
assertEquals("/786/:id", routes.get(routes.size() - 1).pattern());
chain.next(req, rsp);
}).name("r2");
get("/786/:id", req -> {
return req.param("id").value();
}).name("r3");
Copyright © 2019. All rights reserved.