use of org.eclipse.jetty.server.handler.ConnectHandler in project saga by timurstrekalov.
the class InstrumentingProxyServer method start.
public int start() {
final SelectChannelConnector connector = new SelectChannelConnector();
connector.setPort(0);
server.addConnector(connector);
final HandlerCollection handlers = new HandlerCollection();
// Setup proxy servlet
final ServletContextHandler context = new ServletContextHandler(handlers, "/");
context.setAttribute(InstrumentingProxyServlet.INSTRUMENTER, instrumenter);
context.addServlet(new ServletHolder(InstrumentingProxyServlet.class), "/*");
// Setup proxy handler to handle CONNECT methods
final ConnectHandler connectProxy = new ConnectHandler();
handlers.addHandler(connectProxy);
server.setHandler(handlers);
try {
server.start();
logger.info("Proxy server started on port {}", connector.getLocalPort());
} catch (final Exception e) {
throw new RuntimeException(e);
}
return connector.getLocalPort();
}
Aggregations