Search in sources :

Example 1 with HttpServer

use of io.vertx.rxjava.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().toObservable().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.rxjava.core.http.HttpServer)

Example 2 with HttpServer

use of io.vertx.rxjava.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().toObservable().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.rxjava.core.http.HttpServer) JsonObject(io.vertx.core.json.JsonObject)

Example 3 with HttpServer

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

Example 4 with HttpServer

use of io.vertx.rxjava.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().toObservable().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.rxjava.core.http.HttpServer)

Example 5 with HttpServer

use of io.vertx.rxjava.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().toObservable().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.rxjava.core.http.HttpServer) JsonObject(io.vertx.core.json.JsonObject)

Aggregations

HttpServer (io.vertx.rxjava.core.http.HttpServer)8 JsonObject (io.vertx.core.json.JsonObject)2 HttpServerResponse (io.vertx.rxjava.core.http.HttpServerResponse)1