use of io.vertx.reactivex.ext.web.RoutingContext 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());
}
}
use of io.vertx.reactivex.ext.web.RoutingContext in project knotx by Cognifide.
the class SupportedMethodsAndPathsHandlerTest method handle_whenRequestPathNotAllowedInDefaultFlowAndAllowedInCustomFlow_expectRequestAccepted.
@Test
public void handle_whenRequestPathNotAllowedInDefaultFlowAndAllowedInCustomFlow_expectRequestAccepted() throws Exception {
RoutingContext context = mockContext("/services/feature.json", HttpMethod.GET);
tested.handle(context);
Mockito.verify(context, Mockito.times(1)).next();
}
use of io.vertx.reactivex.ext.web.RoutingContext in project knotx by Cognifide.
the class SupportedMethodsAndPathsHandlerTest method handle_whenRequestPathAndMethodAllowedInDefaultFlow_expectRequestAccepted.
@Test
public void handle_whenRequestPathAndMethodAllowedInDefaultFlow_expectRequestAccepted() throws Exception {
RoutingContext context = mockContext("/content/page.html", HttpMethod.GET);
tested.handle(context);
Mockito.verify(context, Mockito.times(1)).next();
}
use of io.vertx.reactivex.ext.web.RoutingContext in project knotx by Cognifide.
the class KnotxGatewayContextHandler method handle.
@Override
public void handle(RoutingContext context) {
KnotContext knotContext = context.get(KnotContext.KEY);
String bodyAsString = context.getBodyAsString();
if (StringUtils.isNotBlank(bodyAsString)) {
knotContext.setFragments(Collections.singletonList(Fragment.raw(bodyAsString)));
}
LOGGER.debug("CustomFlow: Routing the traffic to '{}'", address);
proxies.computeIfAbsent(address, adr -> KnotProxy.createProxyWithOptions(vertx, adr, configuration.getDeliveryOptions())).rxProcess(knotContext).doOnSuccess(ctx -> context.put(KnotContext.KEY, ctx)).subscribe(ctx -> {
context.put(KnotContext.KEY, ctx);
context.next();
}, error -> {
LOGGER.error("Error happened while communicating with {} engine", error, address);
context.fail(error);
});
}
Aggregations