Annotation 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 conjunction 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);
 }
 
Since:
1.0
Author:
Ahmed Lafta
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
     
    If used on a class level with @RequestAttributes this is the attribute name and value is the value.
    If used as a bound parameter, this is the attribute name.