Java Code Examples for io.vertx.reactivex.core.http.HttpServerResponse#write()

The following examples show how to use io.vertx.reactivex.core.http.HttpServerResponse#write() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VertxSecurityDomainHandler.java    From graviteeio-access-management with Apache License 2.0 5 votes vote down vote up
private void sendNotFound(RoutingContext context) {
    // Send a NOT_FOUND HTTP status code (404)  if domain's sub url didn't match any route.
    HttpServerResponse serverResponse = context.response();
    serverResponse.setStatusCode(HttpStatusCode.NOT_FOUND_404);

    String message = environment.getProperty("http.domain.errors[404].message", "No endpoint matches the request URI.");
    serverResponse.headers().set(HttpHeaders.CONTENT_LENGTH, Integer.toString(message.length()));
    serverResponse.headers().set(HttpHeaders.CONTENT_TYPE, "text/plain");
    serverResponse.headers().set(HttpHeaders.CONNECTION, HttpHeadersValues.CONNECTION_CLOSE);
    serverResponse.write(Buffer.buffer(message));

    serverResponse.end();
}
 
Example 2
Source File: DefaultReactor.java    From graviteeio-access-management with Apache License 2.0 5 votes vote down vote up
private void sendNotFound(HttpServerResponse serverResponse) {
    // Send a NOT_FOUND HTTP status code (404)
    serverResponse.setStatusCode(HttpStatusCode.NOT_FOUND_404);

    String message = environment.getProperty("http.errors[404].message", "No security domain matches the request URI.");
    serverResponse.headers().set(HttpHeaders.CONTENT_LENGTH, Integer.toString(message.length()));
    serverResponse.headers().set(HttpHeaders.CONTENT_TYPE, "text/plain");
    serverResponse.headers().set(HttpHeaders.CONNECTION, HttpHeadersValues.CONNECTION_CLOSE);
    serverResponse.write(Buffer.buffer(message));

    serverResponse.end();
}