@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); }
@AliasFor(annotation=Bindable.class, member="value") public abstract String value
@AliasFor(annotation=Bindable.class, member="value") public abstract String name
@AliasFor(annotation=Bindable.class, member="defaultValue") public abstract String defaultValue
Bindable.defaultValue()