users@jersey.java.net

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

From: Erik Holstad <erikholstad_at_gmail.com>
Date: Mon, 24 Mar 2014 14:02:11 -0700

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