<div dir="ltr">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?<div><br></div><div>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.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Dec 10, 2016 at 6:30 AM, Christian Krampenschiesser <span dir="ltr"><<a href="mailto:krampenschiesser@gmail.com" target="_blank">krampenschiesser@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I added those 2 tests to RoutingHandlerTestCase:<div><br></div><div><pre style="color:rgb(0,0,0);font-family:"dejavu sans mono";font-size:9pt"><span style="color:rgb(128,128,0)">@Test<br></span><span style="color:rgb(0,0,128);font-weight:bold">public void </span>testWildCardRoutingTemplateHan<wbr>dler2() <span style="color:rgb(0,0,128);font-weight:bold">throws </span>IOException {<br> TestHttpClient client = <span style="color:rgb(0,0,128);font-weight:bold">new </span>TestHttpClient();<br> <span style="color:rgb(0,0,128);font-weight:bold">try </span>{<br> HttpGet get = <span style="color:rgb(0,0,128);font-weight:bold">new </span>HttpGet(DefaultServer.<span style="font-style:italic">getDefau<wbr>ltServerURL</span>() + <span style="color:rgb(0,128,0);font-weight:bold">"/wilder/test/card"</span>);<br> HttpResponse result = client.execute(get);<br> Assert.<span style="font-style:italic">assertEquals</span>(<wbr>StatusCodes.<span style="color:rgb(102,14,122);font-weight:bold;font-style:italic">OK</span>, result.getStatusLine().<wbr>getStatusCode());<br> Assert.<span style="font-style:italic">assertEquals</span>(<span style="color:rgb(0,128,0);font-weight:bold">"wilder:[/<wbr>test/card]"</span>, HttpClientUtils.<span style="font-style:italic">readResponse</span>(<wbr>result));<br><br> } <span style="color:rgb(0,0,128);font-weight:bold">finally </span>{<br> client.getConnectionManager().<wbr>shutdown();<br> }<br>}<br><br><span style="color:rgb(128,128,0)">@Test<br></span><span style="color:rgb(0,0,128);font-weight:bold">public void </span>testWildCardRoutingTemplateHan<wbr>dler3() <span style="color:rgb(0,0,128);font-weight:bold">throws </span>IOException {<br> TestHttpClient client = <span style="color:rgb(0,0,128);font-weight:bold">new </span>TestHttpClient();<br> <span style="color:rgb(0,0,128);font-weight:bold">try </span>{<br> HttpGet get = <span style="color:rgb(0,0,128);font-weight:bold">new </span>HttpGet(DefaultServer.<span style="font-style:italic">getDefau<wbr>ltServerURL</span>() + <span style="color:rgb(0,128,0);font-weight:bold">"/wildestBeast"</span>);<br> HttpResponse result = client.execute(get);<br> Assert.<span style="font-style:italic">assertEquals</span>(<wbr>StatusCodes.<span style="color:rgb(102,14,122);font-weight:bold;font-style:italic">OK</span>, result.getStatusLine().<wbr>getStatusCode());<br> Assert.<span style="font-style:italic">assertEquals</span>(<span style="color:rgb(0,128,0);font-weight:bold">"wildest:[<wbr>Beast]"</span>, HttpClientUtils.<span style="font-style:italic">readResponse</span>(<wbr>result));<br><br> } <span style="color:rgb(0,0,128);font-weight:bold">finally </span>{<br> client.getConnectionManager().<wbr>shutdown();<br> }<br>}</pre><pre style="color:rgb(0,0,0);font-family:"dejavu sans mono";font-size:9pt">Additional routes are:<br></pre><pre style="color:rgb(0,0,0);font-family:"dejavu sans mono";font-size:9pt"><pre style="font-family:"dejavu sans mono";font-size:9pt">.add(Methods.<span style="color:rgb(102,14,122);font-weight:bold;font-style:italic">GET</span>, <span style="color:rgb(0,128,0);font-weight:bold">"/wilder/*"</span>, <span style="color:rgb(0,0,128);font-weight:bold">new </span>HttpHandler() {<br> <span style="color:rgb(128,128,0)">@Override<br></span><span style="color:rgb(128,128,0)"> </span><span style="color:rgb(0,0,128);font-weight:bold">public void </span>handleRequest(<wbr>HttpServerExchange exchange) <span style="color:rgb(0,0,128);font-weight:bold">throws </span>Exception {<br> exchange.getResponseSender().<wbr>send(<span style="color:rgb(0,128,0);font-weight:bold">"wilder:" </span>+ exchange.getQueryParameters().<wbr>get(<span style="color:rgb(0,128,0);font-weight:bold">"*"</span>));<br> }<br>})<br>.add(Methods.<span style="color:rgb(102,14,122);font-weight:bold;font-style:italic">GET</span>, <span style="color:rgb(0,128,0);font-weight:bold">"/wildest*"</span>, <span style="color:rgb(0,0,128);font-weight:bold">new </span>HttpHandler() {<br> <span style="color:rgb(128,128,0)">@Override<br></span><span style="color:rgb(128,128,0)"> </span><span style="color:rgb(0,0,128);font-weight:bold">public void </span>handleRequest(<wbr>HttpServerExchange exchange) <span style="color:rgb(0,0,128);font-weight:bold">throws </span>Exception {<br> exchange.getResponseSender().<wbr>send(<span style="color:rgb(0,128,0);font-weight:bold">"wildest:" </span>+ exchange.getQueryParameters().<wbr>get(<span style="color:rgb(0,128,0);font-weight:bold">"*"</span>));<br> }<br>})</pre><pre style="font-family:"dejavu sans mono";font-size:9pt"><br></pre><pre style="font-family:"dejavu sans mono";font-size:9pt">Now the problem is that without a part representing the wildcard at the pathtemplate the <b>PathTemplateMatcher</b> doesn't work, and therefore the routing doesn't too.</pre><pre style="font-family:"dejavu sans mono";font-size:9pt">However when I try to fix the <b>PathTemplate</b> the actual matching doesn't work.</pre><pre style="font-family:"dejavu sans mono";font-size:9pt">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.</pre><pre style="font-family:"dejavu sans mono";font-size:9pt">Enhance the <b>PathTemplateMatcher#match</b> to handle the index of c correctly(which is complicated because wrong base in pathTemplates)</pre><pre style="font-family:"dejavu sans mono";font-size:9pt">or fix <b>PathTemplate#matches </b>and <b>PathTemplate#create</b></pre><pre style="font-family:"dejavu sans mono";font-size:9pt">I would be really happy to get some feedback, right now I feel more like mangling with the PathTemplate because it seems to be</pre><pre style="font-family:"dejavu sans mono";font-size:9pt">called only at creation/instantiation time instead of the Matcher which is called with every request.</pre></pre></div></div>
<br>______________________________<wbr>_________________<br>
undertow-dev mailing list<br>
<a href="mailto:undertow-dev@lists.jboss.org">undertow-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/undertow-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/<wbr>mailman/listinfo/undertow-dev</a><br></blockquote></div><br></div>