I didn't think the RoutingHandler currently supports wildcards. I'm also
not sure what syntax you are using. Path parameters are handled using
"/path/{param}". Yours is fetching query parameters but there is no query
string so I am confused how it is working at all?
I achieved wildcards by mixing a PathHandler and a RoutingHandler. I use
pathPrefix routes from the path handler for wildcards and RoutingHandler
for the exact routes.
On Sat, Dec 10, 2016 at 6:30 AM, Christian Krampenschiesser <
krampenschiesser(a)gmail.com> wrote:
I added those 2 tests to RoutingHandlerTestCase:
@Test
public void testWildCardRoutingTemplateHandler2() throws IOException {
TestHttpClient client = new TestHttpClient();
try {
HttpGet get = new HttpGet(DefaultServer.getDefaultServerURL() +
"/wilder/test/card");
HttpResponse result = client.execute(get);
Assert.assertEquals(StatusCodes.OK, result.getStatusLine().getStatusCode());
Assert.assertEquals("wilder:[/test/card]",
HttpClientUtils.readResponse(result));
} finally {
client.getConnectionManager().shutdown();
}
}
@Test
public void testWildCardRoutingTemplateHandler3() throws IOException {
TestHttpClient client = new TestHttpClient();
try {
HttpGet get = new HttpGet(DefaultServer.getDefaultServerURL() +
"/wildestBeast");
HttpResponse result = client.execute(get);
Assert.assertEquals(StatusCodes.OK, result.getStatusLine().getStatusCode());
Assert.assertEquals("wildest:[Beast]",
HttpClientUtils.readResponse(result));
} finally {
client.getConnectionManager().shutdown();
}
}
Additional routes are:
.add(Methods.GET, "/wilder/*", new HttpHandler() {
@Override
public void handleRequest(HttpServerExchange exchange) throws Exception {
exchange.getResponseSender().send("wilder:" +
exchange.getQueryParameters().get("*"));
}
})
.add(Methods.GET, "/wildest*", new HttpHandler() {
@Override
public void handleRequest(HttpServerExchange exchange) throws Exception {
exchange.getResponseSender().send("wildest:" +
exchange.getQueryParameters().get("*"));
}
})
Now the problem is that without a part representing the wildcard at the pathtemplate the
*PathTemplateMatcher* doesn't work, and therefore the routing doesn't too.
However when I try to fix the *PathTemplate* the actual matching doesn't work.
I have no problem digging a bit and fixing this issue, I just want to know which class
should be the preferred class to fix it.
Enhance the *PathTemplateMatcher#match* to handle the index of c correctly(which is
complicated because wrong base in pathTemplates)
or fix *PathTemplate#matches *and *PathTemplate#create*
I would be really happy to get some feedback, right now I feel more like mangling with
the PathTemplate because it seems to be
called only at creation/instantiation time instead of the Matcher which is called with
every request.
_______________________________________________
undertow-dev mailing list
undertow-dev(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/undertow-dev