use of com.hotels.styx.common.http.handler.HttpAggregator in project styx by ExpediaGroup.
the class AdminServerBuilder method extensionEndpoints.
private static List<Route> extensionEndpoints(String root, String name, Map<String, HttpHandler> endpoints) {
List<AdminEndpointRoute> routes = extensionAdminEndpointRoutes(root, name, endpoints);
List<IndexHandler.Link> endpointLinks = routes.stream().map(AdminEndpointRoute::link).collect(toList());
WebServiceHandler handler = endpointLinks.isEmpty() ? new StaticBodyHttpHandler(HTML, format("This plugin (%s) does not expose any admin interfaces", name)) : new IndexHandler(endpointLinks);
Route indexRoute = new Route(adminPath(root, name), new HttpAggregator(MEGABYTE, handler));
return concatenate(indexRoute, routes);
}
use of com.hotels.styx.common.http.handler.HttpAggregator in project styx by ExpediaGroup.
the class StyxProxyTest method startsServerWithHttpConnector.
@Test
public void startsServerWithHttpConnector() {
HttpInterceptor echoInterceptor = (request, chain) -> textResponse("Response from http connector");
StandardHttpRouter handler = new StandardHttpRouter();
InetServer styxServer = newBuilder().setProtocolConnector(connector(0)).bossExecutor(NettyExecutor.create("Test-Server-Boss", 1)).workerExecutor(NettyExecutor.create("Test-Server-Worker", 0)).handler(new HttpInterceptorPipeline(List.of(echoInterceptor), (request, context) -> new HttpAggregator(new StandardHttpRouter()).handle(request, context), false)).build();
Service server = StyxServers.toGuavaService(styxServer);
server.startAsync().awaitRunning();
assertThat("Server should be running", server.isRunning());
HttpResponse secureResponse = get("http://localhost:" + styxServer.inetAddress().getPort());
assertThat(secureResponse.bodyAs(UTF_8), containsString("Response from http connector"));
server.stopAsync().awaitTerminated();
assertThat("Server should not be running", !server.isRunning());
}
Aggregations