I'm working on an application that provides a local rest service. To do this I use resteasy
(3.5.0) and for server com.sun.net.httpserver.HttpServer
. My goal is to include the CORS
header in the all replies.
According to the documentation, resteasy
provides a CorsFilter
filter that puts the header, but nowhere can I find documentation on how I can use it in my case (without using an application server). And at all, how do I make some specific configuration.
I am currently writing this header manually, in each method
@Path("/api")
public class Endpoint {
@GET
@Path("version")
@Produces(MediaType.APPLICATION_JSON)
public Response version() {
return Response.ok(new Version())
.header("Access-Control-Allow-Origin", "*")
.build();
}
}