How to set HTTP header in RESTEasy client framework?

前端 未结 4 695
栀梦
栀梦 2021-01-31 11:19

RESTEasy (a JAX-RS implementation) has a nice client framework, eg:

RegisterBuiltin.register(ResteasyProviderFactory.getInstance());

SimpleClient client = Proxy         


        
4条回答
  •  情话喂你
    2021-01-31 12:01

    In your client proxy interface, use the @HeaderParam annotation:

    public interface SimpleClient
    {
       @PUT
       @Path("basic")
       @Consumes("text/plain")
       public void putBasic(@HeaderParam("Greeting") String greeting);
    }
    

    The call in your example above would add an HTTP header that looks like this:

    Greeting: hello world
    

提交回复
热议问题