use of com.linecorp.armeria.common.HttpRequest in project curiostack by curioswitch.
the class GoogleCredentialsDecoratingClient method execute.
@Override
@SuppressWarnings("FutureReturnValueIgnored")
public HttpResponse execute(ClientRequestContext ctx, HttpRequest req) {
CompletableFuture<HttpResponse> resFuture = new CompletableFuture<>();
credentials.getRequestMetadata(URI.create(req.path()), authExecutor, new RequestMetadataCallback() {
@Override
public void onSuccess(Map<String, List<String>> metadata) {
metadata.forEach((key, values) -> {
for (String value : values) {
req.headers().add(HttpHeaderNames.of(key), value);
}
});
try {
ctx.contextAwareEventLoop().submit(() -> resFuture.complete(delegate().execute(ctx, req)));
} catch (Exception e) {
resFuture.completeExceptionally(e);
}
}
@Override
public void onFailure(Throwable t) {
resFuture.completeExceptionally(t);
}
});
return HttpResponse.from(resFuture);
}
Aggregations