![JAR search and dependency download from the Maven repository](/logo.png)
com.gitee.easyopen.spring.boot.autoconfigure.EasyopenAutoConfiguration Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of easyopen-spring-boot-starter Show documentation
Show all versions of easyopen-spring-boot-starter Show documentation
easyopen-spring-boot-starter(JDK8)
package com.gitee.easyopen.spring.boot.autoconfigure;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;
import com.gitee.easyopen.ApiConfig;
import com.gitee.easyopen.ApiResult;
import com.gitee.easyopen.config.ConfigClient;
import com.gitee.easyopen.interceptor.ApiInterceptor;
import com.gitee.easyopen.limit.ApiLimitConfigLocalManager;
import com.gitee.easyopen.limit.ApiLimitManager;
import com.gitee.easyopen.message.Errors;
import com.gitee.easyopen.support.ApiController;
import reactor.core.publisher.Mono;
/**
* @author tanghc
*/
@org.springframework.context.annotation.Configuration
@EnableConfigurationProperties(EasyopenProperties.class)
public class EasyopenAutoConfiguration {
private final EasyopenProperties properties;
// application.properties中的配置会注入到EasyopenProperties中
public EasyopenAutoConfiguration(EasyopenProperties properties) {
this.properties = properties;
}
@Bean
@ConditionalOnMissingBean
public ApiConfig apiConfig() {
return new ApiConfig();
}
/**
* 跨域过滤器
*
* @return
*/
@Bean
@ConditionalOnProperty(prefix = "easyopen", name = "cors", havingValue = "true", matchIfMissing = true)
public CorsFilter corsFilter() {
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", buildConfig());
return new CorsFilter(source);
}
@Bean
@ConditionalOnMissingBean
public CorsConfiguration buildConfig() {
CorsConfiguration corsConfiguration = new CorsConfiguration();
corsConfiguration.addAllowedOrigin("*");
corsConfiguration.addAllowedHeader("*");
corsConfiguration.addAllowedMethod("*");
return corsConfiguration;
}
/**
* 默认入口
*/
@Controller
@RequestMapping("api")
public class EayopenIndexController extends ApiController {
private static final String OPEN_MONO = "true";
@Autowired
private ApiConfig config;
@Autowired(required = false)
private RedisTemplate redisTemplate;
@Value("${easyopen.mono}")
private String mono;
@RequestMapping("mono")
@ResponseBody
public Mono
© 2015 - 2025 Weber Informatics LLC | Privacy Policy