Search in sources :

Example 1 with ClientVersioningConfiguration

use of io.micronaut.http.client.interceptor.configuration.ClientVersioningConfiguration in project micronaut-core by micronaut-projects.

the class VersionClientRequestBinder method bind.

@Override
public void bind(@NonNull MethodInvocationContext<Object, Object> context, @NonNull ClientRequestUriContext uriContext, @NonNull MutableHttpRequest<?> request) {
    context.findAnnotation(Version.class).flatMap(AnnotationValue::stringValue).filter(StringUtils::isNotEmpty).ifPresent(version -> {
        ClientVersioningConfiguration configuration = getVersioningConfiguration(context.getAnnotationMetadata());
        configuration.getHeaders().forEach(header -> request.header(header, version));
        configuration.getParameters().forEach(parameter -> uriContext.addQueryParameter(parameter, version));
    });
}
Also used : ClientVersioningConfiguration(io.micronaut.http.client.interceptor.configuration.ClientVersioningConfiguration) Version(io.micronaut.core.version.annotation.Version) AnnotationValue(io.micronaut.core.annotation.AnnotationValue)

Aggregations

AnnotationValue (io.micronaut.core.annotation.AnnotationValue)1 Version (io.micronaut.core.version.annotation.Version)1 ClientVersioningConfiguration (io.micronaut.http.client.interceptor.configuration.ClientVersioningConfiguration)1