Example usage for org.apache.http.impl.bootstrap ServerBootstrap registerHandler

List of usage examples for org.apache.http.impl.bootstrap ServerBootstrap registerHandler

Introduction

In this page you can find the example usage for org.apache.http.impl.bootstrap ServerBootstrap registerHandler.

Prototype

public final ServerBootstrap registerHandler(final String pattern, final HttpRequestHandler handler) 

Source Link

Document

Registers the given HttpRequestHandler as a handler for URIs matching the given pattern.

Usage

From source file:com.adobe.ags.curly.test.TestWebServer.java

private TestWebServer(int port) throws IOException, InterruptedException {
    this.port = port;
    ServerBootstrap bootstrap = ServerBootstrap.bootstrap();
    bootstrap.setListenerPort(port);/*from  ww w.j ava2  s  .  c om*/
    bootstrap.setServerInfo("Test/1.1");
    bootstrap.setSocketConfig(SocketConfig.DEFAULT);
    bootstrap.registerHandler("*", this::handleHttpRequest);
    server = bootstrap.create();
    server.start();
}

From source file:brooklyn.test.TestHttpServer.java

public TestHttpServer start() {
    checkNotStarted();/*from   ww w.  j av a  2  s .c  om*/

    HttpProcessor httpProcessor = new ImmutableHttpProcessor(requestInterceptors, responseInterceptors);
    int port = Networking.nextAvailablePort(basePort);
    ServerBootstrap bootstrap = ServerBootstrap.bootstrap().setListenerPort(port)
            .setLocalAddress(getLocalAddress()).setHttpProcessor(httpProcessor);

    for (HandlerTuple tuple : handlers) {
        bootstrap.registerHandler(tuple.path, tuple.handler);
    }
    server = bootstrap.create();

    try {
        server.start();
    } catch (IOException e) {
        throw Exceptions.propagate(e);
    }

    return this;
}