spring云网关全局cors配置不能用@refreshscope刷新?

xxb16uws  于 2021-07-08  发布在  Java
关注(0)|答案(0)|浏览(217)

问题是:
当我尝试刷新我的配置包括网关路由和cors配置时,只有网关路由被刷新而没有重新启动我的应用程序。
我查了一些SpringCloudGateway的源代码,发现只有gateway有一些 EventListener 去Spring Cloud门 RefreshRouteEvent .
下面是spring云网关cors配置

spring:
  cloud:
    gateway:
      globalcors:
        add-to-simple-url-handler-mapping: true
        corsConfigurations:
          '[/demo/integration/**]':
            allowedOrigins: "*"
            allowedHeaders: "*"
            allowedMethods: "*"
          '[/demo/provider/**]':
            allowedOrigins: "*"
            allowedHeaders: "*"
            allowedMethods: "*"

下面来自spring-cloud-gateway-core-2.2.5.release.jar (org.springframework.spring.cloud.gateway.handler.RoutePredicateHandlerMapping) ```
@Override
protected CorsConfiguration getCorsConfiguration(Object handler,
ServerWebExchange exchange) {
// TODO: support cors configuration via properties on a route see gh-229
// see RequestMappingHandlerMapping.initCorsConfiguration()
// also see
// https://github.com/spring-projects/spring-framework/blob/master/spring-web/src/test/java/org/springframework/web/cors/reactive/CorsWebFilterTests.java
return super.getCorsConfiguration(handler, exchange);
}

这个可以吗( `via properties on a route` )未来的spring云网关版本是否支持?
关于这个有什么发展路线图吗?
怎么回事 `gh-229` 什么意思?我找不到任何以 `gh-229` 在github回购中。
我想实施 `RoutePredicateHandlerMapping` 和修改 `#getCorsConfiguration()` ,否则添加一些要侦听的事件 `ContextRefresher` 触发时重新加载网关全局cors配置 `#refersh()` . 我说得对吗?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题