Package io.micronaut.http.annotation
Annotation Type Header
-
@Documented @Retention(RUNTIME) @Target({FIELD,PARAMETER,TYPE,METHOD,ANNOTATION_TYPE}) @Repeatable(Headers.class) @Bindable @Inherited public @interface HeaderAn 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
Clientannotation:@Header(name="X-Username",value='Freddy'), @Header(name="X-MyParam",value='${foo.bar}') @Client('/users') interface UserClient { }When declared as a binding annotation the
@Headerannotation 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); }- Since:
- 1.0
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description java.lang.StringdefaultValuejava.lang.StringnameIf used on a class level with @Headers this is the header name and value is the value.java.lang.StringvalueIf used as a bound parameter, this is the header name.
-
-
-
Element Detail
-
value
@AliasFor(annotation=io.micronaut.core.bind.annotation.Bindable.class, member="value") java.lang.String valueIf used as a bound parameter, this is the header name. If used on a class level this is value and not the header name.- Returns:
- The name of the header, otherwise it is inferred from the parameter name
- Default:
- ""
-
-