List of usage examples for io.vertx.core.http HttpServerResponse push
@Fluent
default HttpServerResponse push(HttpMethod method, String path,
Handler<AsyncResult<HttpServerResponse>> handler)
From source file:examples.HTTP2Examples.java
License:Open Source License
public void example6(HttpServerRequest request) { HttpServerResponse response = request.response(); // Push main.js to the client response.push(HttpMethod.GET, "/main.js", ar -> { if (ar.succeeded()) { // The server is ready to push the response HttpServerResponse pushedResponse = ar.result(); // Send main.js response pushedResponse.putHeader("content-type", "application/json").end("alert(\"Push response hello\")"); } else {/*from ww w. j a v a2 s . c o m*/ System.out.println("Could not push client resource " + ar.cause()); } }); // Send the requested resource response.sendFile("<html><head><script src=\"/main.js\"></script></head><body></body></html>"); }