Quantcast
Channel: Active questions tagged rest - Stack Overflow
Viewing all articles
Browse latest Browse all 3655

How do I implement a default functionality for HTTP Method in JAX-RS?

$
0
0

I am using JAX-RS and it has default implementations for @OPTIONS and @HEAD methods, but I would like to provide a different functionality.

What I have done currently is this:

@GET@Path("path/to/resource")@Produces(MediaType.APPLICATION_JSON)public Response resourceCall(){    // Normal method implementation}@OPTIONS@Path("path/to/resource")@Produces(MediaType.APPLICATION_JSON)public Response resourceCall(){    Response.status(Response.Status.METHOD_NOT_ALLOWED).build();}

So, basically I create a new call to each one of my resources. But, I would like to have a catch-all method here that would treat all my calls to @OPTION or to @HEAD.

How do I implement such functionality?

EDIT:

Just for clarity. I know how to do this using a Servlet Filter but, I am wondering if JAX-RS has a similar feature built-in for this specific case.


Viewing all articles
Browse latest Browse all 3655

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>