use of io.micronaut.http.annotation.Header in project micronaut-core by micronaut-projects.
the class HeaderClientRequestBinder method bind.
@Override
public void bind(@NonNull MethodInvocationContext<Object, Object> context, @NonNull ClientRequestUriContext uriContext, @NonNull MutableHttpRequest<?> request) {
List<AnnotationValue<Header>> headerAnnotations = context.getAnnotationValuesByType(Header.class);
for (AnnotationValue<Header> headerAnnotation : headerAnnotations) {
String headerName = headerAnnotation.stringValue("name").orElse(null);
String headerValue = headerAnnotation.stringValue().orElse(null);
MutableHttpHeaders headers = request.getHeaders();
if (StringUtils.isNotEmpty(headerName) && StringUtils.isNotEmpty(headerValue) && !headers.contains(headerName)) {
headers.set(headerName, headerValue);
}
}
}
Aggregations