org.zalando.riptide.BlockingIO Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of riptide-core Show documentation
Show all versions of riptide-core Show documentation
Client side response routing
The newest version!
package org.zalando.riptide;
import lombok.AllArgsConstructor;
import org.springframework.http.HttpMethod;
import org.springframework.http.client.ClientHttpRequest;
import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.http.client.ClientHttpResponse;
import java.io.IOException;
import java.net.URI;
import java.util.concurrent.CompletableFuture;
import static java.util.concurrent.CompletableFuture.completedFuture;
@AllArgsConstructor
final class BlockingIO implements IO {
private final ClientHttpRequestFactory requestFactory;
@Override
public CompletableFuture execute(final RequestArguments arguments) throws IOException {
final URI uri = arguments.getRequestUri();
final HttpMethod method = arguments.getMethod();
final ClientHttpRequest request = requestFactory.createRequest(uri, method);
copyTo(arguments.getHeaders(), request.getHeaders());
arguments.getEntity().writeTo(request);
return completedFuture(request.execute());
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy