<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p style="margin-top:0;margin-bottom:0">Stuart:</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">Many thanks for the changes. Where I can get the version 1.4.23.Final?</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">Best Regards</p>
<br>
<div style="color: rgb(0, 0, 0);">
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Stuart Douglas <sdouglas@redhat.com><br>
<b>Sent:</b> Monday, January 22, 2018 9:25 PM<br>
<b>To:</b> Fernando Cruz<br>
<b>Subject:</b> Re: Handlers routing</font>
<div> </div>
</div>
<div>
<div dir="ltr">
<div>This looks like a bug, I have filed <a href="https://issues.jboss.org/browse/UNDERTOW-1272" id="LPlnk472396" previewremoved="true">https://issues.jboss.org/browse/UNDERTOW-1272</a>.</div>
<div><br>
</div>
<div>I am a bit worried that it may cause minor compat problems, but if so they can be fixed by removing the trailing / from the template.</div>
<div><br>
<div>Stuart</div>
</div>
</div>
<div class="x_gmail_extra"><br>
<div class="x_gmail_quote">On Tue, Jan 23, 2018 at 4:40 AM, Fernando Cruz <span dir="ltr">
<<a href="mailto:boggard@hotmail.com" target="_blank">boggard@hotmail.com</a>></span> wrote:<br>
<blockquote class="x_gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div dir="ltr">
<div id="x_m_-3187669535850122436divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:#000000; font-family:Calibri,Helvetica,sans-serif">
<p style="margin-top:0; margin-bottom:0"><span style="font-size:11pt">Hi,</span><br>
</p>
<div style="color:rgb(0,0,0)">
<div class="x_m_-3187669535850122436BodyFragment"><font size="2"><span style="font-size:11pt">
<div class="x_m_-3187669535850122436PlainText"><br>
I have an issue with the path template for the built in handler "Handlers.routing", when execute this implementation:<br>
<br>
public class UndertowOnePathVariableApplica<wbr>tion {<br>
<br>
private static final Logger LOGGER = LoggerFactory.getLogger(<wbr>UndertowOnePathVariableApplica<wbr>tion.class);<br>
<br>
public static void main(final String[] args) {<br>
<br>
Undertow.builder()<br>
.addHttpListener(8080, "localhost")<br>
.setHandler(<br>
Handlers.routing()<br>
.get("/api/v1/orders/", (exchange) -> {<br>
LOGGER.info("The path template defined is '/api/v1/orders/'");<br>
LOGGER.info("The request URI '{}' and URL '{}'", exchange.getRequestURI(), exchange.getRequestURL());<br>
exchange.getResponseHeaders().<wbr>put(Headers.CONTENT_TYPE, "text/plain");<br>
exchange.setStatusCode(<wbr>StatusCodes.OK)<br>
.getResponseSender().send("All Orders");<br>
})<br>
.get("/api/v1/orders/{orderId}<wbr>", (exchange) -> {<br>
LOGGER.info("The path template defined is '/api/v1/orders/{orderId}'");<br>
LOGGER.info("The request URI '{}' and URL '{}'", exchange.getRequestURI(), exchange.getRequestURL());<br>
exchange.getResponseHeaders().<wbr>put(Headers.CONTENT_TYPE, "text/plain");<br>
exchange.setStatusCode(<wbr>StatusCodes.OK)<br>
.getResponseSender().send(<br>
"Order '" + exchange.getQueryParameters().<wbr>get("orderId").getLast() + "'");<br>
}))<br>
.build()<br>
.start();<br>
<br>
}<br>
<br>
}<br>
<br>
I get this responses:<br>
<br>
boggard@xiuhcoatl:~$ curl -v '<a href="http://localhost:8080/api/v1/orders" id="x_m_-3187669535850122436LPlnk364853" target="_blank">http://localhost:8080/api/v1/<wbr>orders</a>'<br>
* Trying 127.0.0.1...<br>
* TCP_NODELAY set<br>
* Connected to localhost (127.0.0.1) port 8080 (#0)<br>
> GET /api/v1/orders HTTP/1.1<br>
> Host: localhost:8080<br>
> User-Agent: curl/7.56.0<br>
> Accept: */*<br>
><br>
< HTTP/1.1 404 Not Found<br>
< Connection: keep-alive<br>
< Content-Length: 0<br>
< Date: Sun, 21 Jan 2018 02:01:53 GMT<br>
<<br>
* Connection #0 to host localhost left intact<br>
<br>
boggard@xiuhcoatl:~$ curl -v '<a href="http://localhost:8080/api/v1/orders/" id="x_m_-3187669535850122436LPlnk208681" target="_blank">http://localhost:8080/api/v1/<wbr>orders/</a>'<br>
* Trying 127.0.0.1...<br>
* TCP_NODELAY set<br>
* Connected to localhost (127.0.0.1) port 8080 (#0)<br>
> GET /api/v1/orders/ HTTP/1.1<br>
> Host: localhost:8080<br>
> User-Agent: curl/7.56.0<br>
> Accept: */*<br>
><br>
< HTTP/1.1 200 OK<br>
< Connection: keep-alive<br>
< Content-Type: text/plain<br>
< Content-Length: 10<br>
< Date: Sun, 21 Jan 2018 02:02:45 GMT<br>
<<br>
* Connection #0 to host localhost left intact<br>
All Orders<br>
<br>
boggard@xiuhcoatl:~$ curl -v '<a href="http://localhost:8080/api/v1/orders/12345" target="_blank">http://localhost:8080/api/v1/<wbr>orders/12345</a>'<br>
* Trying 127.0.0.1...<br>
* TCP_NODELAY set<br>
* Connected to localhost (127.0.0.1) port 8080 (#0)<br>
> GET /api/v1/orders/12345 HTTP/1.1<br>
> Host: localhost:8080<br>
> User-Agent: curl/7.56.0<br>
> Accept: */*<br>
><br>
< HTTP/1.1 200 OK<br>
< Connection: keep-alive<br>
< Content-Type: text/plain<br>
< Content-Length: 13<br>
< Date: Sun, 21 Jan 2018 02:03:56 GMT<br>
<<br>
* Connection #0 to host localhost left intact<br>
Order '12345'<br>
<br>
That I thing is correct because I just define two paths: '.../orders/' and '.../orders/{orderId}'. And the path '.../orders', that is not defined, respond 404. But when use this implementation:<br>
<br>
public class UndertowTwoPathVariablesApplic<wbr>ation {<br>
<br>
private static final Logger LOGGER = LoggerFactory.getLogger(<wbr>UndertowTwoPathVariablesApplic<wbr>ation.class);<br>
<br>
public static void main(final String[] args) {<br>
<br>
Undertow.builder()<br>
.addHttpListener(8080, "localhost")<br>
.setHandler(<br>
Handlers.routing()<br>
.get("/api/v1/orders/{orderId}<wbr>/items/", (exchange) -> {<br>
LOGGER.info("The path template defined is '/api/v1/orders/{orderId}/<wbr>items/'");<br>
LOGGER.info("The request URI '{}' and URL '{}'", exchange.getRequestURI(), exchange.getRequestURL());<br>
exchange.getResponseHeaders().<wbr>put(Headers.CONTENT_TYPE, "text/plain");<br>
exchange.setStatusCode(<wbr>StatusCodes.OK)<br>
.getResponseSender().send(<br>
"Order '" + exchange.getQueryParameters().<wbr>get("orderId").getLast() + "'");<br>
})<br>
.get("/api/v1/orders/{orderId}<wbr>/items/{itemId}", (exchange) -> {<br>
LOGGER.info("The path template defined is '/api/v1/orders/{orderId}/<wbr>items/{itemId}'");<br>
LOGGER.info("The request URI '{}' and URL '{}'", exchange.getRequestURI(), exchange.getRequestURL());<br>
exchange.getResponseHeaders().<wbr>put(Headers.CONTENT_TYPE, "text/plain");<br>
exchange.setStatusCode(<wbr>StatusCodes.OK)<br>
.getResponseSender().send(<br>
"Order '" + exchange.getQueryParameters().<wbr>get("orderId").getLast() +<br>
"' Item '" + exchange.getQueryParameters().<wbr>get("itemId").getLast() + "'");<br>
}))<br>
.build()<br>
.start();<br>
<br>
}<br>
<br>
}<br>
<br>
I get this responses:<br>
<br>
boggard@xiuhcoatl:~$ curl -v '<a href="http://localhost:8080/api/v1/orders/12345/items" target="_blank">http://localhost:8080/api/v1/<wbr>orders/12345/items</a>'<br>
* Trying 127.0.0.1...<br>
* TCP_NODELAY set<br>
* Connected to localhost (127.0.0.1) port 8080 (#0)<br>
> GET /api/v1/orders/12345/items HTTP/1.1<br>
> Host: localhost:8080<br>
> User-Agent: curl/7.56.0<br>
> Accept: */*<br>
><br>
< HTTP/1.1 200 OK<br>
< Connection: keep-alive<br>
< Content-Type: text/plain<br>
< Content-Length: 13<br>
< Date: Sun, 21 Jan 2018 02:08:45 GMT<br>
<<br>
* Connection #0 to host localhost left intact<br>
Order '12345'<br>
<br>
boggard@xiuhcoatl:~$ curl -v '<a href="http://localhost:8080/api/v1/orders/12345/items/" target="_blank">http://localhost:8080/api/v1/<wbr>orders/12345/items/</a>'<br>
* Trying 127.0.0.1...<br>
* TCP_NODELAY set<br>
* Connected to localhost (127.0.0.1) port 8080 (#0)<br>
> GET /api/v1/orders/12345/items/ HTTP/1.1<br>
> Host: localhost:8080<br>
> User-Agent: curl/7.56.0<br>
> Accept: */*<br>
><br>
< HTTP/1.1 200 OK<br>
< Connection: keep-alive<br>
< Content-Type: text/plain<br>
< Content-Length: 21<br>
< Date: Sun, 21 Jan 2018 02:09:11 GMT<br>
<<br>
* Connection #0 to host localhost left intact<br>
Order '12345' Item ''<br>
<br>
boggard@xiuhcoatl:~$ curl -v '<a href="http://localhost:8080/api/v1/orders/12345/items/09876" target="_blank">http://localhost:8080/api/v1/<wbr>orders/12345/items/09876</a>'<br>
* Trying 127.0.0.1...<br>
* TCP_NODELAY set<br>
* Connected to localhost (127.0.0.1) port 8080 (#0)<br>
> GET /api/v1/orders/12345/items/<wbr>09876 HTTP/1.1<br>
> Host: localhost:8080<br>
> User-Agent: curl/7.56.0<br>
> Accept: */*<br>
><br>
< HTTP/1.1 200 OK<br>
< Connection: keep-alive<br>
< Content-Type: text/plain<br>
< Content-Length: 26<br>
< Date: Sun, 21 Jan 2018 02:09:30 GMT<br>
<<br>
* Connection #0 to host localhost left intact<br>
Order '12345' Item '09876'<br>
<br>
That I thing is incorrect because there are just two paths again: '.../orders/{orderId}/items/' and '.../orders/{orderId}/items/{<wbr>itemId}' but the curl with the exact URI use the second path template. Is this an issue or what I am doing wrong?<br>
<br>
Best Regards<span class="x_HOEnZb"><font color="#888888"><br>
<br>
Fernando Cruz<br>
</font></span></div>
</span></font></div>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</div>
</body>
</html>