Vertx HttpServer debugging Router routes not dispaching

136 views
Skip to first unread message

Pat S

unread,
Apr 25, 2017, 2:22:45 PM4/25/17
to vert.x
I wrote a simply example program that created two Routes and it worked.
I'm now trying to using code in an actual application and the Routing is not working.

The code simply logs the URI passed and returns "Hello $URI" so there is no static content.

When I try to hit the web endpoint:  http://localhost:8080/anything/can-go/here
I receive the text "Resource not found" in the browser indicating that the code that is supposed to return Hello /anything/can-go/here.

I used the debugger and stopped in HttpServerImpl.doMessageReceived() and can see the web request come in, and later enabled trace level debugging so I can see the browser's request hit the HttpServer.

Any pointers to displaying/logging the routes associated with a web server?

Thanks,
Patrick
Message has been deleted
Message has been deleted

Pat S

unread,
Apr 25, 2017, 2:40:46 PM4/25/17
to vert.x
Nevermind.  It was a copy/paste error.

I had code that looked like this:

void initialize(){
    Router router = Router.router(vertx);  // <<<< THIS was the bug/problem

    HttpServer httpServer = vertx.createHttpServer();
    setupRoutes();
    httpServer.requestHandler(router::accept);
}

The code was setting up routes using a different "Router" than the one I associated with the HttpServer.
If I changed the one line to this:

    httpServer.requestHandler(this.router::accept);

the code works properly.

NOTE: I still am curious how to dump the Routes on an HttpServer but I've fixed the dispatching not working problem.

Reply all
Reply to author
Forward
0 new messages