Code example for HttpRequestHandlerRegistry

Methods: register

        public static final String TAG = "HttpServer";
        private final int port;
        private RequestListenerThread requestListenerThread;
    private HttpRequestHandlerRegistry registry = new HttpRequestHandlerRegistry();
        private boolean running = false;
    public BasicHttpServer(final int port, final AssetManager assetManager) {
        this.port = port;
        addRequestHandler("*", new HttpFileHandler(assetManager));
     * You may add some HttpRequestHandlers before calling start() 
     * All HttpRequestHandlers added after start() will be ignored 
     * @param pattern Patterns may have three formats: * or *<uri> or <uri>* 
     * @param handler A request handler 
    public void addRequestHandler(String pattern, HttpRequestHandler handler) {
        registry.register(pattern, handler);
    public void start() throws IOException { 
        if (running) return;
        requestListenerThread = new RequestListenerThread(port, registry);