删除 CorsConfig 配置, 使用 Spring 注解 @CrossOrigin.

pull/28/head
chen.ma 3 years ago
parent f97e0d78bb
commit 135b0d7ad9

@ -1,31 +0,0 @@
package cn.hippo4j.starter.config;
import org.springframework.context.annotation.Bean;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;
/**
* Cors config.
*
* @author chen.ma
* @date 2021/11/12 21:46
*/
public class CorsConfig {
private CorsConfiguration buildConfig() {
CorsConfiguration corsConfiguration = new CorsConfiguration();
corsConfiguration.addAllowedOrigin("*");
corsConfiguration.addAllowedHeader("*");
corsConfiguration.addAllowedMethod("GET");
return corsConfiguration;
}
@Bean
public CorsFilter corsFilter() {
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", buildConfig());
return new CorsFilter(source);
}
}

@ -32,7 +32,7 @@ import org.springframework.core.env.ConfigurableEnvironment;
@AllArgsConstructor @AllArgsConstructor
@ConditionalOnBean(MarkerConfiguration.Marker.class) @ConditionalOnBean(MarkerConfiguration.Marker.class)
@EnableConfigurationProperties(BootstrapProperties.class) @EnableConfigurationProperties(BootstrapProperties.class)
@ImportAutoConfiguration({HttpClientConfig.class, DiscoveryConfig.class, MessageAlarmConfig.class, UtilAutoConfiguration.class, CorsConfig.class}) @ImportAutoConfiguration({HttpClientConfig.class, DiscoveryConfig.class, MessageAlarmConfig.class, UtilAutoConfiguration.class})
public class DynamicThreadPoolAutoConfiguration { public class DynamicThreadPoolAutoConfiguration {
private final BootstrapProperties properties; private final BootstrapProperties properties;

@ -1,9 +1,10 @@
package cn.hippo4j.starter.controller; package cn.hippo4j.starter.controller;
import cn.hippo4j.starter.handler.ThreadPoolRunStateHandler;
import cn.hippo4j.common.model.PoolRunStateInfo; import cn.hippo4j.common.model.PoolRunStateInfo;
import cn.hippo4j.common.web.base.Result; import cn.hippo4j.common.web.base.Result;
import cn.hippo4j.common.web.base.Results; import cn.hippo4j.common.web.base.Results;
import cn.hippo4j.starter.handler.ThreadPoolRunStateHandler;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@ -14,6 +15,7 @@ import org.springframework.web.bind.annotation.RestController;
* @author chen.ma * @author chen.ma
* @date 2021/7/7 21:34 * @date 2021/7/7 21:34
*/ */
@CrossOrigin
@RestController @RestController
public class PoolRunStateController { public class PoolRunStateController {

Loading…
Cancel
Save