Search in sources :

Example 1 with ComposerProxySlice

use of com.artipie.composer.http.proxy.ComposerProxySlice 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);
}
Also used : ComposerProxySlice(com.artipie.composer.http.proxy.ComposerProxySlice) AstoRepository(com.artipie.composer.AstoRepository) ProxyConfig(com.artipie.repo.ProxyConfig) ComposerStorageCache(com.artipie.composer.http.proxy.ComposerStorageCache)

Aggregations

AstoRepository (com.artipie.composer.AstoRepository)1 ComposerProxySlice (com.artipie.composer.http.proxy.ComposerProxySlice)1 ComposerStorageCache (com.artipie.composer.http.proxy.ComposerStorageCache)1 ProxyConfig (com.artipie.repo.ProxyConfig)1