@Retention(value=CLASS)
@Target(value={METHOD,TYPE})
public @interface RequiresHeader
Use on Get
, Post
, … annotated methods to inject a header in
the request.
The annotation value()
is mandatory and define the header's name you
want to inject.
To set a header's value you MUST either let your RestClient interface extends
of RestClientHeaders
or add the following method to your interface :
void setHeader(String name, String value)
.
You can also add the getter version to read a header value :
void getHeader(String name)
.
Example :@Rest(rootUrl = "http://myserver", converters = MappingJacksonHttpMessageConverter.class) public interface MyRestClient { @Get("/events/{id}") @RequiresHeader("myHeader") Event getEvent(long id); void setHeader(String name, String value); String getHeader(String name); } @EBean public class MyBean { @RestService MyRestClient; @AfterInject public void init() { myRestClient.setHeader("myHeader", "myValue"); } }
Modifier and Type | Required Element and Description |
---|---|
java.lang.String[] |
value |
Copyright © 2010-2014. All Rights Reserved.