|
|
@ -16,8 +16,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
package org.springframework.boot.actuate.autoconfigure.endpoint.web.reactive;
|
|
|
|
package org.springframework.boot.actuate.autoconfigure.endpoint.web.reactive;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.boot.actuate.autoconfigure.endpoint.web.CorsEndpointProperties;
|
|
|
|
import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties;
|
|
|
|
import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties;
|
|
|
|
import org.springframework.boot.actuate.autoconfigure.endpoint.web.servlet.CorsEndpointProperties;
|
|
|
|
|
|
|
|
import org.springframework.boot.actuate.autoconfigure.web.ManagementContextConfiguration;
|
|
|
|
import org.springframework.boot.actuate.autoconfigure.web.ManagementContextConfiguration;
|
|
|
|
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
|
|
|
|
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
|
|
|
|
import org.springframework.boot.actuate.endpoint.web.EndpointMediaTypes;
|
|
|
|
import org.springframework.boot.actuate.endpoint.web.EndpointMediaTypes;
|
|
|
@ -32,8 +32,6 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
|
|
|
|
import org.springframework.boot.endpoint.web.EndpointMapping;
|
|
|
|
import org.springframework.boot.endpoint.web.EndpointMapping;
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
import org.springframework.http.server.reactive.HttpHandler;
|
|
|
|
import org.springframework.http.server.reactive.HttpHandler;
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
|
|
import org.springframework.web.cors.CorsConfiguration;
|
|
|
|
|
|
|
|
import org.springframework.web.reactive.DispatcherHandler;
|
|
|
|
import org.springframework.web.reactive.DispatcherHandler;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -58,31 +56,7 @@ public class WebFluxEndpointManagementContextConfiguration {
|
|
|
|
WebEndpointProperties webEndpointProperties) {
|
|
|
|
WebEndpointProperties webEndpointProperties) {
|
|
|
|
return new WebFluxEndpointHandlerMapping(
|
|
|
|
return new WebFluxEndpointHandlerMapping(
|
|
|
|
new EndpointMapping(webEndpointProperties.getBasePath()),
|
|
|
|
new EndpointMapping(webEndpointProperties.getBasePath()),
|
|
|
|
endpointDiscoverer.discoverEndpoints(), endpointMediaTypes, getCorsConfiguration(corsProperties));
|
|
|
|
endpointDiscoverer.discoverEndpoints(), endpointMediaTypes, corsProperties.toCorsConfiguration());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private CorsConfiguration getCorsConfiguration(CorsEndpointProperties properties) {
|
|
|
|
|
|
|
|
if (CollectionUtils.isEmpty(properties.getAllowedOrigins())) {
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
CorsConfiguration configuration = new CorsConfiguration();
|
|
|
|
|
|
|
|
configuration.setAllowedOrigins(properties.getAllowedOrigins());
|
|
|
|
|
|
|
|
if (!CollectionUtils.isEmpty(properties.getAllowedHeaders())) {
|
|
|
|
|
|
|
|
configuration.setAllowedHeaders(properties.getAllowedHeaders());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!CollectionUtils.isEmpty(properties.getAllowedMethods())) {
|
|
|
|
|
|
|
|
configuration.setAllowedMethods(properties.getAllowedMethods());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!CollectionUtils.isEmpty(properties.getExposedHeaders())) {
|
|
|
|
|
|
|
|
configuration.setExposedHeaders(properties.getExposedHeaders());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (properties.getMaxAge() != null) {
|
|
|
|
|
|
|
|
configuration.setMaxAge(properties.getMaxAge().getSeconds());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (properties.getAllowCredentials() != null) {
|
|
|
|
|
|
|
|
configuration.setAllowCredentials(properties.getAllowCredentials());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return configuration;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|