use of io.vertx.ext.web.Route in project vertx-web by vert-x3.
the class TemplateHandlerImplTest method testDefaultIndex.
@Test
public void testDefaultIndex() {
TemplateEngine templateEngine = mock(TemplateEngine.class);
RoutingContext routingContext = mock(RoutingContext.class);
when(routingContext.normalisedPath()).thenReturn("/");
Route currentRoute = mock(Route.class);
when(currentRoute.getPath()).thenReturn("/");
when(routingContext.currentRoute()).thenReturn(currentRoute);
TemplateHandler templateHandler = new TemplateHandlerImpl(templateEngine, "templates", "ext");
templateHandler.handle(routingContext);
verify(templateEngine).render(any(), eq("templates"), eq("/index"), any());
}
use of io.vertx.ext.web.Route in project vertx-web by vert-x3.
the class RouterImpl method getAndCheckRoutePath.
private String getAndCheckRoutePath(RoutingContext ctx) {
Route currentRoute = ctx.currentRoute();
String path = currentRoute.getPath();
if (path == null) {
throw new IllegalStateException("Sub routers must be mounted on constant paths (no regex or patterns)");
}
return path;
}
use of io.vertx.ext.web.Route in project vertx-web by vert-x3.
the class BlockingHandlerDecorator method handle.
@Override
public void handle(RoutingContext context) {
Route currentRoute = context.currentRoute();
context.vertx().executeBlocking(fut -> {
decoratedHandler.handle(new RoutingContextDecorator(currentRoute, context));
fut.complete();
}, ordered, res -> {
if (res.failed()) {
// This means an exception was thrown from the blocking handler
context.fail(res.cause());
}
});
}
use of io.vertx.ext.web.Route in project vertx-zero by silentbalanceyh.
the class EventAxis method mount.
/**
* Secreter for security limitation
* 1. Authorization
* 2. Authorize
*/
@Override
public void mount(final Router router) {
// Extract Event foreach
EVENTS.forEach(event -> {
// Build Route and connect to each Action
Fn.safeSemi(null == event, LOGGER, () -> LOGGER.warn(Info.NULL_EVENT, getClass().getName()), () -> {
// 1. Verify
Verifier.verify(event);
final Route route = router.route();
// 2. Path, Method, Order
Hub<Route> hub = Fn.poolThread(Pool.URIHUBS, () -> Instance.instance(UriHub.class));
hub.mount(route, event);
// 3. Consumes/Produces
hub = Fn.poolThread(Pool.MEDIAHUBS, () -> Instance.instance(MediaHub.class));
hub.mount(route, event);
// 4. Request validation
final Depot depot = Depot.create(event);
// 5. Request workflow executor: handler
final Aim<RoutingContext> aim = this.splitter.distribute(event);
/**
* 6. Handler chain
* 1) Mime Analyzer ( Build arguments )
* 2) Validation
* 3) Execute handler ( Code Logical )
* 4) Uniform failure handler
*/
route.handler(this.verifier.signal(depot)).handler(aim.attack(event)).failureHandler(CommonEndurer.create());
});
});
}
use of io.vertx.ext.web.Route in project vertx-zero by silentbalanceyh.
the class FilterAxis method mount.
@Override
public void mount(final Router router) {
// Extract Event foreach
FILTERS.forEach((path, events) -> events.forEach(event -> Fn.safeSemi(null == event, LOGGER, () -> LOGGER.warn(Info.NULL_EVENT, this.getClass().getName()), () -> {
// Path for filter
final Route route = router.route();
Hub<Route> hub = Fn.poolThread(Pool.URIHUBS, () -> Instance.instance(UriHub.class));
hub.mount(route, event);
// Consumes/Produces
hub = Fn.poolThread(Pool.MEDIAHUBS, () -> Instance.instance(MediaHub.class));
hub.mount(route, event);
// Filter Handler execution
route.handler(context -> {
// Execute method
final Method method = event.getAction();
final Object proxy = event.getProxy();
// Call
this.execute(context, proxy, method);
});
})));
}
Aggregations