All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.zodiac.autoconfigure.feign.context.ServletIstioFeignContextAutoConfiguration Maven / Gradle / Ivy

There is a newer version: 1.6.8
Show newest version
package org.zodiac.autoconfigure.feign.context;

import java.util.Objects;

import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type;
import org.springframework.context.annotation.Bean;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.zodiac.autoconfigure.feign.condition.ConditionalOnFeignEnabled;
import org.zodiac.autoconfigure.feign.condition.ConditionalOnFeignIstioEnabled;
import org.zodiac.autoconfigure.feign.istio.FeignIstioConfigProperties;

@SpringBootConfiguration
@ConditionalOnFeignEnabled
@ConditionalOnFeignIstioEnabled
@ConditionalOnWebApplication(type = Type.SERVLET)
@ConditionalOnClass(value = {feign.Client.class, io.fabric8.kubernetes.client.Client.class, org.zodiac.feign.core.consumer.FeignConsumerClientProviderType.class, org.zodiac.feign.istio.FeignIstio.class})
public class ServletIstioFeignContextAutoConfiguration {

    public ServletIstioFeignContextAutoConfiguration() {
    }

    @Bean
    @ConditionalOnMissingBean
    protected org.zodiac.feign.istio.context.IstioBasicContextCoprocessor istioBasicContextCoprocessor(
        FeignIstioConfigProperties feignIstioConfigProperties) {
        return new org.zodiac.feign.istio.context.servlet.ServletIstioBasicContextCoprocessor(feignIstioConfigProperties);
    }

    @Bean
    @ConditionalOnMissingBean
    protected org.zodiac.feign.istio.context.IstioTracingContextCoprocessor istioTracingContextCoprocessor(
        FeignIstioConfigProperties feignIstioConfigProperties) {
        return new org.zodiac.feign.istio.context.servlet.ServletIstioTracingContextCoprocessor(feignIstioConfigProperties);
    }

    @Bean
    @ConditionalOnMissingBean
    protected org.zodiac.feign.istio.context.servlet.IstioFeignContextServletInterceptor istioFeignContextServletInterceptor() {
        return new org.zodiac.feign.istio.context.servlet.IstioFeignContextServletInterceptor();
    }

    @Bean
    protected IstioFeignContextWebMvcConfigurer istioFeignContextWebMvcConfigurer(
        org.zodiac.feign.istio.context.servlet.IstioFeignContextServletInterceptor interceptor) {
        return new IstioFeignContextWebMvcConfigurer(interceptor);
    }

    static class IstioFeignContextWebMvcConfigurer implements WebMvcConfigurer {

        private final org.zodiac.feign.istio.context.servlet.IstioFeignContextServletInterceptor interceptor;

        public IstioFeignContextWebMvcConfigurer(org.zodiac.feign.istio.context.servlet.IstioFeignContextServletInterceptor interceptor) {
            this.interceptor = Objects.requireNonNull(interceptor, "interceptor");
        }

        @Override
        public void addInterceptors(InterceptorRegistry registry) {
            registry.addInterceptor(interceptor).addPathPatterns("/**");
        }
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy