use of io.knotx.dataobjects.KnotContext in project knotx by Cognifide.
the class KnotxGatewayResponseProviderHandler method handle.
@Override
public void handle(RoutingContext context) {
KnotContext knotContext = context.get(KnotContext.KEY);
if (isOkClientResponse(knotContext.getClientResponse())) {
responseProviderProxy.rxProcess(knotContext).doOnSuccess(this::traceMessage).subscribe(ctx -> {
if (isOkClientResponse(ctx.getClientResponse())) {
sendResponse(context, ctx.getClientResponse());
} else {
context.fail(ctx.getClientResponse().getStatusCode());
}
}, error -> {
LOGGER.error("Error {} happened while communicating with `{}` engine", error, configuration.getCustomFlow().responseProviderAddress());
context.fail(error);
});
} else {
sendResponse(context, knotContext.getClientResponse());
}
}
use of io.knotx.dataobjects.KnotContext in project knotx by Cognifide.
the class ServiceKnotProxyImpl method processError.
@Override
protected KnotContext processError(KnotContext knotContext, Throwable error) {
LOGGER.error("Error happened during Template processing", error);
ClientResponse errorResponse = new ClientResponse().setStatusCode(HttpResponseStatus.INTERNAL_SERVER_ERROR.code());
return new KnotContext().setClientRequest(knotContext.getClientRequest()).setClientResponse(errorResponse);
}
use of io.knotx.dataobjects.KnotContext in project knotx by Cognifide.
the class FragmentAssemblerTest method callAssemblerWithAssertions.
private void callAssemblerWithAssertions(TestContext context, List<Pair<List<String>, String>> fragments, Action1<KnotContext> testFunction) {
Async async = context.async();
KnotProxy service = KnotProxy.createProxy(new Vertx(vertx.vertx()), ADDRESS);
service.rxProcess(KnotContextFactory.create(fragments)).map(ctx -> Pair.of(async, ctx)).doOnSuccess(success -> testFunction.call(success.getRight())).subscribe(success -> async.complete(), context::fail);
}
use of io.knotx.dataobjects.KnotContext in project knotx by Cognifide.
the class HtmlFragmentSplitterVerticleTest method callFragmentSplitterWithAssertions.
private void callFragmentSplitterWithAssertions(TestContext context, String template, Action1<KnotContext> testFunction) {
Async async = context.async();
KnotProxy service = KnotProxy.createProxy(new Vertx(vertx.vertx()), ADDRESS);
service.rxProcess(KnotContextFactory.empty(template)).map(ctx -> Pair.of(async, ctx)).doOnSuccess(success -> testFunction.call(success.getRight())).subscribe(success -> async.complete(), context::fail);
}
use of io.knotx.dataobjects.KnotContext 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());
}
}
Aggregations