[undertow-dev] REST routing

Jonathan Hart jonathan.hart at gmail.com
Mon Apr 21 00:09:14 EDT 2014


Thanks for the tip. I was only able to get the parameters if the
constructor for the RoutingHandler was set to true (rewrite as query
params).

If it is set to false, I'm not seeing them show up in pathParameters. It is
still null.


On Sun, Apr 20, 2014 at 8:03 PM, Bill O'Neil <bill at dartalley.com> wrote:

> I believe by default all path parameters will be written as query
> parameters.  You can read them the same way you read query parameters.
>  However if you have a path parameter and a query parameter with the same
> name this can cause issues.  There is a flag to NOT rewrite path parameters
> as query params if you wish to use that.  There is a second way to get the
> path parameter values but I cannot remember it off of the top of my head.
>
>
> On Sun, Apr 20, 2014 at 10:59 PM, Jonathan Hart <jonathan.hart at gmail.com>wrote:
>
>> Stuart,
>>
>> I was able to successfully set up a RoutingHandler, and it is matching
>> templates correctly. However, how do I get access to the {variable} data
>> itself once inside my matched handler?
>>
>> I have looked through all of the Handler methods/props and the only place
>> I see the values are in the relative path, which would require me to
>> re-parse the URL to get to the data I need..
>>
>> A quick example is:
>>
>> /user/{userId}
>>
>> Which is matched when someone requests something like:
>>
>> /user/5
>>
>> How do I get access to the "5"? Perhaps I'm too new to Undertow to miss
>> something obvious, but some advice would be appreciated!
>>
>>
>> On Tue, Apr 15, 2014 at 6:16 PM, Bill O'Neil <oneil5045 at gmail.com> wrote:
>>
>>> Thanks for the quick response.  This is exactly what I was looking for.
>>>
>>> Bill
>>>
>>>
>>> On Tue, Apr 15, 2014 at 7:27 PM, Jonathan Hart <jonathan.hart at gmail.com>wrote:
>>>
>>>> Hi everyone (new to this list)
>>>>
>>>> Many thanks for making this, I was trying to do the EXACT same thing
>>>> with Undertow and was having a very hard time wrapping my head around
>>>> predicates.
>>>>
>>>>
>>>> On Mon, Apr 14, 2014 at 5:38 PM, Stuart Douglas <sdouglas at redhat.com>wrote:
>>>>
>>>>>
>>>>>
>>>>> Bill O'Neil wrote:
>>>>> > I was curious what the best practices would be for url routing with
>>>>> many
>>>>> > endpoints.
>>>>> >
>>>>> > For example
>>>>> >
>>>>> > POST /user/
>>>>> > GET /user/{userId}
>>>>> > GET /document/{documentId} ContentType=appliction/json (only respond
>>>>> > when json is requested)
>>>>> >
>>>>> > What would be the best option for this? I was able to achieve most of
>>>>> > what i wanted using the PredicatesHandler class. Is this a good
>>>>> choice?
>>>>>
>>>>> That will work fine, although there are more efficient ways to do this.
>>>>> I think this will actually be a fairly common use case, so I have added
>>>>> a handler to handle this:
>>>>>
>>>>>
>>>>> https://github.com/undertow-io/undertow/commit/04385f29996673658bce3c131de4e0a32241e78e#diff-3
>>>>>
>>>>>
>>>>> Basically it matches requests based on a combination of method, path
>>>>> template and predicate, and will be considerably more efficient that
>>>>> testing a list of predicates.
>>>>>
>>>>> Stuart
>>>>>
>>>>>
>>>>>
>>>>> >
>>>>> > This would build a List of PredicatedHandlers as well as the fall
>>>>> > through handler which I would use as a 404. I got an example working
>>>>> > using the text predicate format
>>>>> >
>>>>> > method[GET] and path-template[value=\"/user/{userId}\"]
>>>>> >
>>>>> >
>>>>> > Is this a good approach or are there better recommendations?
>>>>> >
>>>>> >
>>>>> > Thanks,
>>>>> >
>>>>> > Bill
>>>>> >
>>>>> > _______________________________________________
>>>>> > undertow-dev mailing list
>>>>> > undertow-dev at lists.jboss.org
>>>>> > https://lists.jboss.org/mailman/listinfo/undertow-dev
>>>>> _______________________________________________
>>>>> undertow-dev mailing list
>>>>> undertow-dev at lists.jboss.org
>>>>> https://lists.jboss.org/mailman/listinfo/undertow-dev
>>>>>
>>>>
>>>>
>>>
>>
>> _______________________________________________
>> undertow-dev mailing list
>> undertow-dev at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/undertow-dev
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/undertow-dev/attachments/20140420/62f61e80/attachment-0001.html 


More information about the undertow-dev mailing list