@Documented @Retention(value=RUNTIME) @Target(value={PARAMETER,TYPE,METHOD,ANNOTATION_TYPE}) @Repeatable(value=RequestAttributes.class) @Bindable public @interface RequestAttribute
An annotation that can be applied to method arguments to indicate that the method argument is bound to an HTTP request attribute This can also be used in conjuction with @RequestAttributes to list attributes on a client class that will always be applied Note: Request attributes are intended for internal data sharing only, and are not attached to the outbound request.
The following example demonstrates usage at the type level to declare default values to pass in the request when using the Client
annotation;
@RequestAttribute(name="X-Username",value='Freddy'), @RequestAttribute(name="X-MyParam",value='${foo.bar}') @Client('/users') interface UserClient { }
When declared as a binding annotation the @RequestAttribute
annotation is declared on each parameter to be bound:
@Get('/user') User get(@RequestAttribute('X-Username') String username, @RequestAttribute('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 @RequestAttributes this is the attribute name and value is the value.
|
java.lang.String |
value
If used as a bound parameter, this is the attribute 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()