Search in sources :

Example 1 with RepositoryEntry

use of io.knotx.server.configuration.RepositoryEntry in project knotx by Cognifide.

the class KnotxRepositoryHandler method handle.

@Override
public void handle(RoutingContext context) {
    final Optional<RepositoryEntry> repositoryEntry = configuration.getDefaultFlow().repositoryForPath(context.request().path());
    final KnotContext knotContext = context.get(KnotContext.KEY);
    if (repositoryEntry.isPresent()) {
        proxies.computeIfAbsent(repositoryEntry.get().address(), adr -> RepositoryConnectorProxy.createProxyWithOptions(vertx, adr, configuration.getDeliveryOptions())).rxProcess(knotContext.getClientRequest()).doOnSuccess(this::traceMessage).subscribe(repoResponse -> handleRepositoryResponse(repoResponse, context, repositoryEntry.get(), knotContext), context::fail);
    } else {
        context.fail(HttpResponseStatus.NOT_FOUND.code());
    }
}
Also used : KnotContext(io.knotx.dataobjects.KnotContext) RepositoryConnectorProxy(io.knotx.reactivex.proxy.RepositoryConnectorProxy) HttpResponseStatus(io.netty.handler.codec.http.HttpResponseStatus) HashMap(java.util.HashMap) HttpServerResponse(io.vertx.reactivex.core.http.HttpServerResponse) RoutingContext(io.vertx.reactivex.ext.web.RoutingContext) LoggerFactory(io.vertx.core.logging.LoggerFactory) ClientResponse(io.knotx.dataobjects.ClientResponse) RepositoryEntry(io.knotx.server.configuration.RepositoryEntry) MultiMap(io.vertx.reactivex.core.MultiMap) Vertx(io.vertx.reactivex.core.Vertx) Map(java.util.Map) Optional(java.util.Optional) Handler(io.vertx.core.Handler) Logger(io.vertx.core.logging.Logger) KnotxServerConfiguration(io.knotx.server.configuration.KnotxServerConfiguration) Buffer(io.vertx.reactivex.core.buffer.Buffer) KnotContext(io.knotx.dataobjects.KnotContext) RepositoryEntry(io.knotx.server.configuration.RepositoryEntry)

Aggregations

ClientResponse (io.knotx.dataobjects.ClientResponse)1 KnotContext (io.knotx.dataobjects.KnotContext)1 RepositoryConnectorProxy (io.knotx.reactivex.proxy.RepositoryConnectorProxy)1 KnotxServerConfiguration (io.knotx.server.configuration.KnotxServerConfiguration)1 RepositoryEntry (io.knotx.server.configuration.RepositoryEntry)1 HttpResponseStatus (io.netty.handler.codec.http.HttpResponseStatus)1 Handler (io.vertx.core.Handler)1 Logger (io.vertx.core.logging.Logger)1 LoggerFactory (io.vertx.core.logging.LoggerFactory)1 MultiMap (io.vertx.reactivex.core.MultiMap)1 Vertx (io.vertx.reactivex.core.Vertx)1 Buffer (io.vertx.reactivex.core.buffer.Buffer)1 HttpServerResponse (io.vertx.reactivex.core.http.HttpServerResponse)1 RoutingContext (io.vertx.reactivex.ext.web.RoutingContext)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Optional (java.util.Optional)1