I am trying to set a header value in a response from a RESTful endpoint using RESTeasy. I know that I can read header parameters using @HeaderParam but I want to change the value of that header parameter for the response. How can I do this without using a filter?
RESTEasy can inject HttpResponse
which enables you to set header parameters.
@Path("/")
public class MyService {
@Context org.jboss.resteasy.spi.HttpResponse response;
@GET @Path("/") public void setHeader(){
response.getOutputHeaders().putSingle("X-Some-Header", "value");
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With