users@glassfish.java.net

Off topic: Using a default method for unmatched REST methods in Jersey

From: Serkan Camurcuoglu <scamurcuoglu_at_gmail.com>
Date: Fri, 5 Nov 2010 15:29:22 +0200

Hi all,
Since joining the jersey users mailing is temporarily disabled, I decided to
ask a Jersey related question on this list, because it's somewhat urgent
(btw if anyone can forward this to the jersey-users list, then maybe I can
follow the discussion on Nabble).

Anyway, (I know this is not quite "restful" but) I want to learn if and how
I can handle all requests which do not match any of the methods in my REST
resource (I want to proxy these requests to another server and return the
server's response as my own). For example, it could be a method like:

@GET
@Path("*")
public Response defaultMethod(@Context HttpServletRequest request, @Context
HttpServletResponse response)
{
    // do proxying here
}

Is there way I can do this?

BTW, this is what I could think of, but suggestions to achieve the same
result using other means is also welcome. As I mentioned above, my aim is to
proxy unmatched REST requests to another server and return its response.

BR,

SerkanC