Set response headers not using filter - RESTeasy

后端 未结 1 1879
情书的邮戳
情书的邮戳 2021-02-15 12:25

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 valu

相关标签:
1条回答
  • 2021-02-15 12:45

    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");
        }
    }
    
    0 讨论(0)
提交回复
热议问题