http-headersresponsecorsaccess-controlapache-wink

How to handle CORS in Apache Wink?


How can I apply CORS in Apache Wink? What I basically need is adding an Access-Control-Allow-Origin: * header to every response send from Wink (where we will replace the * for the allowed origins).


Solution

  • A possible solution can be returning a javax.ws.rs.core.Response object. Using the javax.ws.rs.core.Response.ResponseBuilder you can add headers to the response.

    Update:

    Another solution is to add a Servlet Filter (javax.servlet.Filter) on top of Wink that will add the headers to all responses.

    Btw, in JAX-RS 2 it's possible to add Filters and Interceptors.