use of io.vertx.reactivex.core.http.HttpServer 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.core.http.HttpServer in project vertx-examples by vert-x3.
the class Server method start.
@Override
public void start() throws Exception {
HttpServer server = vertx.createHttpServer();
server.requestStream().toFlowable().subscribe(req -> {
req.response().putHeader("content-type", "text/html").end("<html><body><h1>Hello from vert.x!</h1></body></html>");
});
server.listen(8080);
}
use of io.vertx.reactivex.core.http.HttpServer in project vertx-examples by vert-x3.
the class Server method start.
@Override
public void start() throws Exception {
Router router = Router.router(vertx);
router.route().handler(BodyHandler.create());
router.route().handler(req -> req.response().putHeader("content-type", "text/html").end("<html><body><h1>Hello from vert.x!</h1></body></html>"));
HttpServer server = vertx.createHttpServer();
server.requestStream().toFlowable().map(HttpServerRequest::pause).onBackpressureDrop(req -> req.response().setStatusCode(503).end()).observeOn(RxHelper.scheduler(vertx.getDelegate())).subscribe(req -> {
req.resume();
router.accept(req);
});
server.rxListen(PORT).subscribe(res -> generateRequests());
}
use of io.vertx.reactivex.core.http.HttpServer in project vertx-examples by vert-x3.
the class Server method start.
@Override
public void start() throws Exception {
HttpServer server = vertx.createHttpServer();
server.requestStream().toFlowable().subscribe(req -> {
req.response().putHeader("content-type", "text/html").end("<html><body><h1>Hello from vert.x!</h1></body></html>");
});
server.listen(8080);
}
use of io.vertx.reactivex.core.http.HttpServer in project vertx-examples by vert-x3.
the class Server method start.
@Override
public void start() throws Exception {
HttpServer server = vertx.createHttpServer();
server.requestStream().toFlowable().subscribe(req -> {
req.response().putHeader("content-type", "application/json").end(new JsonObject().put("time", System.currentTimeMillis()).toString());
});
server.listen(8080);
}
Aggregations