Search in sources :

Example 1 with HttpServer

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);
}
Also used : HttpServer(io.vertx.reactivex.core.http.HttpServer)

Example 2 with HttpServer

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("{\"message\":\"Hello World\"}");
    });
    server.listen(8080);
}
Also used : HttpServer(io.vertx.reactivex.core.http.HttpServer)

Example 3 with HttpServer

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);
}
Also used : HttpServer(io.vertx.reactivex.core.http.HttpServer) JsonObject(io.vertx.core.json.JsonObject)

Example 4 with HttpServer

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 -> {
        HttpServerResponse resp = req.response();
        String contentType = req.getHeader("Content-Type");
        if (contentType != null) {
            resp.putHeader("Content-Type", contentType);
        }
        resp.setChunked(true);
        req.toFlowable().subscribe(resp::write, err -> {
        }, resp::end);
    });
    server.listen(8080);
}
Also used : HttpServerResponse(io.vertx.reactivex.core.http.HttpServerResponse) HttpServer(io.vertx.reactivex.core.http.HttpServer)

Example 5 with HttpServer

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("{\"message\":\"Hello World\"}");
    });
    server.listen(8080);
}
Also used : HttpServer(io.vertx.reactivex.core.http.HttpServer)

Aggregations

HttpServer (io.vertx.reactivex.core.http.HttpServer)11 Router (io.vertx.reactivex.ext.web.Router)3 HttpServerOptions (io.vertx.core.http.HttpServerOptions)2 JsonObject (io.vertx.core.json.JsonObject)2 StartService (in.erail.glue.annotation.StartService)1 Single (io.reactivex.Single)1 AbstractVerticle (io.vertx.reactivex.core.AbstractVerticle)1 HttpServerResponse (io.vertx.reactivex.core.http.HttpServerResponse)1 Route (io.vertx.reactivex.ext.web.Route)1 EventAxis (io.vertx.rx.rs.router.EventAxis)1 RouterAxis (io.vertx.rx.rs.router.RouterAxis)1 Agent (io.vertx.up.annotations.Agent)1 ServerType (io.vertx.up.eon.em.ServerType)1 Fn (io.vertx.up.func.Fn)1 Annal (io.vertx.up.log.Annal)1 ZeroAtomic (io.vertx.up.micro.ZeroAtomic)1 Axis (io.vertx.up.rs.Axis)1 Instance (io.vertx.up.tool.mirror.Instance)1 Values (io.vertx.zero.eon.Values)1 MessageFormat (java.text.MessageFormat)1