mirror of
https://github.com/jlengrand/vert.x.git
synced 2026-03-23 00:41:22 +00:00
HTTP Server Sharing Documentation
Add the paragraph about server sharing and explain the round robin strategy Vert.x uses. Signed-off-by: Clement Escoffier <clement.escoffier@gmail.com>
This commit is contained in:
@@ -90,7 +90,6 @@ public class HTTPExamples {
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void example8(HttpServerRequest request) {
|
||||
|
||||
MultiMap headers = request.headers();
|
||||
@@ -104,9 +103,9 @@ public class HTTPExamples {
|
||||
|
||||
public void example9(HttpServerRequest request) {
|
||||
|
||||
request.handler(buffer -> {
|
||||
System.out.println("I have received a chunk of the body of length " + buffer.length());
|
||||
});
|
||||
request.handler(buffer -> {
|
||||
System.out.println("I have received a chunk of the body of length " + buffer.length());
|
||||
});
|
||||
}
|
||||
|
||||
public void example10(HttpServerRequest request) {
|
||||
@@ -147,7 +146,7 @@ public class HTTPExamples {
|
||||
server.requestHandler(request -> {
|
||||
request.setExpectMultipart(true);
|
||||
request.uploadHandler(upload -> {
|
||||
System.out.println("Got a file upload " + upload.name());
|
||||
System.out.println("Got a file upload " + upload.name());
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -577,4 +576,21 @@ public class HTTPExamples {
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void serversharing(Vertx vertx) {
|
||||
vertx.createHttpServer().requestHandler(request -> {
|
||||
request.response().end("Hello from server " + this);
|
||||
}).listen(8080);
|
||||
}
|
||||
|
||||
public void serversharingclient(Vertx vertx) {
|
||||
vertx.setPeriodic(100, (l) -> {
|
||||
vertx.createHttpClient().getNow(8080, "localhost", "/", resp -> {
|
||||
resp.bodyHandler(body -> {
|
||||
System.out.println(body.toString("ISO-8859-1"));
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user