Example usage for io.vertx.core.http HttpClientRequest end

List of usage examples for io.vertx.core.http HttpClientRequest end

Introduction

In this page you can find the example usage for io.vertx.core.http HttpClientRequest end.

Prototype

@Override
void end(Buffer chunk, Handler<AsyncResult<Void>> handler);

Source Link

Document

Same as #end(String) but with an handler called when the operation completes

Usage

From source file:org.sfs.integration.java.func.KeystoneAuth.java

License:Apache License

@Override
public Observable<HttpClientResponse> call(Void aVoid) {
    return just((Void) null).flatMap(new Func1<Void, Observable<HttpClientResponse>>() {
        @Override/*  ww w .j  a v a2s  .c o  m*/
        public Observable<HttpClientResponse> call(Void aVoid) {
            ObservableFuture<HttpClientResponse> handler = RxHelper.observableFuture();
            HttpClientRequest httpClientRequest = httpClient.post("/v2.0/tokens", handler::complete)
                    .exceptionHandler(handler::fail).setTimeout(10000);

            JsonObject requestJson = new JsonObject().put("auth",
                    new JsonObject().put("tenantName", tenantName).put("passwordCredentials",
                            new JsonObject().put("username", username).put("password", password)));

            httpClientRequest.end(requestJson.encode(), UTF_8.toString());
            return handler.single();
        }
    });

}