use of io.vertx.reactivex.ext.web.Route in project api-framework by vinscom.
the class SessionRouteBuillder method getRouter.
@Override
public Router getRouter(Router pRouter) {
Route route = pRouter.route();
route.handler(BodyHandler.create());
route.handler(CookieHandler.create());
route.handler(SessionHandler.create(getSessionStore()));
return pRouter;
}
use of io.vertx.reactivex.ext.web.Route in project vertx-zero by silentbalanceyh.
the class ZeroRxAgent method recordServer.
private void recordServer(final HttpServerOptions options, final Router router) {
final Integer port = options.getPort();
final AtomicInteger out = ZeroAtomic.RX_START_LOGS.get(port);
if (Values.ZERO == out.getAndIncrement()) {
// 1. Build logs for current server;
final String portLiteral = String.valueOf(port);
LOGGER.info(Info.RX_SERVERS, this.NAME, deploymentID(), portLiteral);
final List<Route> routes = router.getRoutes();
final Map<String, Route> routeMap = new TreeMap<>();
for (final Route route : routes) {
// 2.Route
final String path = null == route.getPath() ? "/*" : route.getPath();
routeMap.put(path, route);
}
routeMap.forEach((path, route) -> LOGGER.info(Info.MAPPED_ROUTE, this.NAME, path, route.toString()));
// 3. Endpoint Publish
final String address = MessageFormat.format("http://{0}:{1}/", options.getHost(), portLiteral);
LOGGER.info(Info.RX_LISTEN, this.NAME, address);
}
}
use of io.vertx.reactivex.ext.web.Route in project vertx-zero by silentbalanceyh.
the class ZeroRxAgent method start.
@Override
public void start() {
/**
* 1.Call router hub to mount commont *
*/
final Axis<Router> routerAxiser = Fn.poolThread(Pool.ROUTERS, () -> Instance.instance(RouterAxis.class));
/**
* 2.Call route hub to mount defined *
*/
final Axis<Router> axiser = Fn.poolThread(Pool.EVENTS, () -> Instance.instance(EventAxis.class));
/**
* 3.Get the default HttpServer Options *
*/
ZeroAtomic.RX_OPTS.forEach((port, option) -> {
/**
* 3.1.Single server processing *
*/
final HttpServer server = this.vertx.createHttpServer(option);
/**
* 3.2. Build router with current option *
*/
final Router router = Router.router(this.vertx);
routerAxiser.mount(router);
axiser.mount(router);
/**
* 3.3. Listen for router on the server *
*/
final Single<HttpServer> result = server.requestHandler(router::accept).rxListen();
/**
* 3.4. Log output *
*/
{
result.subscribe((rxServer) -> {
recordServer(option, router);
});
}
});
}
use of io.vertx.reactivex.ext.web.Route in project vertx-zero by silentbalanceyh.
the class EventAxis method mount.
@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 aim = this.splitter.distribute(event);
route.handler(this.verifier.signal(depot)).failureHandler(ZeroRxEndurer.create());
});
});
}
Aggregations