@Documented @Retention(value=RUNTIME) @Target(value={FIELD,PARAMETER,TYPE,METHOD,ANNOTATION_TYPE}) @Repeatable(value=Headers.class) @Bindable public @interface Header
An annotation that can be applied to method argument to indicate that the method argument is bound from an HTTP header This also can be used in conjunction with @Headers to list headers on a client class that will always be applied.
The following example demonstrates usage at the type level to declare default values to pass in the request when using the Client
annotation:
@Header(name="X-Username",value='Freddy'), @Header(name="X-MyParam",value='${foo.bar}') @Client('/users') interface UserClient { }
When declared as a binding annotation the @Header
annotation is declared on each parameter to be bound:
@Get('/user') User get(@Header('X-Username') String username, @Header('X-MyParam') String myparam) { return new User(username, myparam); }
Modifier and Type | Optional Element and Description |
---|---|
java.lang.String |
defaultValue |
java.lang.String |
name
If used on a class level with @Headers this is the header name and value is the value.
|
java.lang.String |
value
If used as a bound parameter, this is the header name.
|
@AliasFor(annotation=Bindable.class, member="value") public abstract java.lang.String value
@AliasFor(annotation=Bindable.class, member="value") public abstract java.lang.String name
@AliasFor(annotation=Bindable.class, member="defaultValue") public abstract java.lang.String defaultValue
Bindable.defaultValue()