use of com.artipie.composer.http.proxy.ComposerStorageCache in project artipie by artipie.
the class ComposerProxy method response.
@Override
public Response response(final String line, final Iterable<Map.Entry<String, String>> headers, final Publisher<ByteBuffer> body) {
final Collection<? extends ProxyConfig.Remote> remotes = this.cfg.proxy().remotes();
if (remotes.isEmpty()) {
throw new IllegalArgumentException("No remotes were specified");
}
if (remotes.size() > 1) {
throw new IllegalArgumentException("Only one remote is allowed");
}
final ProxyConfig.Remote remote = remotes.iterator().next();
return remote.cache().map(cache -> new ComposerProxySlice(this.client, URI.create(remote.url()), new AstoRepository(this.cfg.storage()), remote.auth(), new ComposerStorageCache(new AstoRepository(cache.storage())))).orElseGet(() -> new ComposerProxySlice(this.client, URI.create(remote.url()), new AstoRepository(this.cfg.storage()), remote.auth())).response(line, headers, body);
}
Aggregations