package com.iailab.framework.env.config;
|
|
import com.iailab.framework.common.enums.WebFilterOrderEnum;
|
import com.iailab.framework.env.core.web.EnvWebFilter;
|
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
import org.springframework.context.annotation.Bean;
|
|
/**
|
* 多环境的 Web 组件的自动配置
|
*
|
* @author iailab
|
*/
|
@AutoConfiguration
|
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET)
|
@EnableConfigurationProperties(EnvProperties.class)
|
public class IailabEnvWebAutoConfiguration {
|
|
/**
|
* 创建 {@link EnvWebFilter} Bean
|
*/
|
@Bean
|
public FilterRegistrationBean<EnvWebFilter> envWebFilterFilter() {
|
EnvWebFilter filter = new EnvWebFilter();
|
FilterRegistrationBean<EnvWebFilter> bean = new FilterRegistrationBean<>(filter);
|
bean.setOrder(WebFilterOrderEnum.ENV_TAG_FILTER);
|
return bean;
|
}
|
|
}
|