use of com.hotels.styx.api.HttpHandler in project styx by ExpediaGroup.
the class RouteHandlerAdapterTest method injectsToPipelineWhenRouteFound.
@Test
public void injectsToPipelineWhenRouteFound() {
HttpHandler pipeline = mock(HttpHandler.class);
when(pipeline.handle(any(LiveHttpRequest.class), any(HttpInterceptor.Context.class))).thenReturn(Eventual.of(respOk));
HttpRouter router = mock(HttpRouter.class);
when(router.route(any(LiveHttpRequest.class), any(HttpInterceptor.Context.class))).thenReturn(Optional.of(pipeline));
LiveHttpResponse response = Mono.from(new RouteHandlerAdapter(router).handle(request, requestContext())).block();
assertThat(response.status(), is(OK));
}
use of com.hotels.styx.api.HttpHandler in project styx by ExpediaGroup.
the class StyxServer method httpServer.
private InetServer httpServer(StyxServerComponents components, ConnectorConfig connectorConfig, HttpHandler styxDataPlane) {
Environment environment = components.environment();
CharSequence styxInfoHeaderName = environment.configuration().styxHeaderConfig().styxInfoHeaderName();
ResponseInfoFormat responseInfoFormat = new ResponseInfoFormat(environment);
ServerConnector proxyConnector = new ProxyConnectorFactory(environment.configuration().proxyServerConfig(), environment.centralisedMetrics(), environment.errorListener(), environment.configuration().get(ENCODE_UNWISECHARS).orElse(""), (builder, request) -> builder.header(styxInfoHeaderName, responseInfoFormat.format(request)), environment.configuration().get("requestTracking", Boolean.class).orElse(false), environment.httpMessageFormatter(), environment.configuration().styxHeaderConfig().originIdHeaderName()).create(connectorConfig);
return NettyServerBuilder.newBuilder().setMetricsRegistry(environment.metricRegistry()).bossExecutor(proxyBossExecutor).workerExecutor(proxyWorkerExecutor).setProtocolConnector(proxyConnector).handler(styxDataPlane).build();
}
use of com.hotels.styx.api.HttpHandler in project styx by ExpediaGroup.
the class StaticPipelineBuilderTest method buildsInterceptorPipelineForBackendServices.
@Test
public void buildsInterceptorPipelineForBackendServices() throws Exception {
HttpHandler handler = new StaticPipelineFactory(clientFactory, environment, registry, List.of(), executor, false).build();
LiveHttpResponse response = Mono.from(handler.handle(get("/foo").build(), requestContext())).block();
assertThat(response.status(), is(OK));
}
Aggregations