users@jersey.java.net

[Jersey] Re: Catch all requests under a specific path

From: Robert DiFalco <robert.difalco_at_gmail.com>
Date: Mon, 24 Mar 2014 14:34:16 -0700

Erik,

I'm not super clear on what you are trying to do here but would a
ContainerRequestFilter work for you?


On Mon, Mar 24, 2014 at 2:28 PM, Ted M. Young [@jitterted] <
tedyoung_at_gmail.com> wrote:

> Ah. Well then I'm not sure what to suggest, other than perhaps consuming
> the logging output as that will have all of the requests in it.
>
> ;ted
>
>
> On Mon, Mar 24, 2014 at 2:02 PM, Erik Holstad <erikholstad_at_gmail.com>wrote:
>
>> I'm planning to use this for testing purposes, so would be nice to
>> capture all requests instead of having to add a new endpoint every time I
>> add a new one to that actual code.
>>
>>
>> On Thu, Mar 20, 2014 at 8:44 PM, Ted M. Young [@jitterted] <
>> tedyoung_at_gmail.com> wrote:
>>
>>> Hi Erik,
>>>
>>> What would the benefit of this be? Why not just create two endpoints
>>> that then call the same method internally? e.g.:
>>>
>>> @Path("/foo")
>>> public class StocksResource {
>>> @GET // just matches /foo
>>> @Produces(MediaType.APPLICATION_JSON)
>>> public Response getFoo() {
>>> return foo(false);
>>> }
>>>
>>> @GET
>>> @Path("/bar") // matches /foo/bar
>>> @Produces(MediaType.APPLICATION_JSON)
>>> public Response getFooBar() {
>>> return foo(true);
>>> }
>>>
>>> private foo(boolean hasBar) {
>>> // do stuff here
>>> }
>>> }
>>>
>>> ;ted
>>>
>>>
>>>
>>> On Thu, Mar 20, 2014 at 4:34 PM, Erik Holstad <erikholstad_at_gmail.com>wrote:
>>>
>>>> Hey!
>>>>
>>>> I wounder if there is a way to route all calls to any sub paths to a
>>>> given parent path.
>>>>
>>>> Let's pretend we have 2 endpoints
>>>>
>>>> GET /foo and
>>>> GET /foo/bar
>>>>
>>>> I would like to be able to catch them both in one method and then
>>>> branch afterwards.
>>>>
>>>> I know I can do this using the regular HttpServletRequest but I just
>>>> want this functionality for one specific path so don't want to change the
>>>> structure of the other servlets.
>>>>
>>>> --
>>>> Regards Erik
>>>>
>>>
>>>
>>
>>
>> --
>> Regards Erik
>>
>
>