public class UrlBasedCorsConfigurationSource extends Object implements CorsConfigurationSource
CorsConfiguration
instance based on a
collection of CorsConfiguration
mapped on path patterns.
Exact path mapping URIs (such as "/admin"
) are supported
as well as Ant-style path patterns (such as "/admin/**"
).
Constructor and Description |
---|
UrlBasedCorsConfigurationSource()
Construct a new
UrlBasedCorsConfigurationSource instance with default
PathPatternParser . |
UrlBasedCorsConfigurationSource(PathPatternParser patternParser)
Construct a new
UrlBasedCorsConfigurationSource instance from the supplied
PathPatternParser . |
Modifier and Type | Method and Description |
---|---|
CorsConfiguration |
getCorsConfiguration(ServerWebExchange exchange)
Return a
CorsConfiguration based on the incoming request. |
void |
registerCorsConfiguration(String path,
CorsConfiguration config)
Register a
CorsConfiguration for the specified path pattern. |
void |
setCorsConfigurations(Map<String,CorsConfiguration> corsConfigurations)
Set CORS configuration based on URL patterns.
|
public UrlBasedCorsConfigurationSource()
UrlBasedCorsConfigurationSource
instance with default
PathPatternParser
.public UrlBasedCorsConfigurationSource(PathPatternParser patternParser)
UrlBasedCorsConfigurationSource
instance from the supplied
PathPatternParser
.public void setCorsConfigurations(@Nullable Map<String,CorsConfiguration> corsConfigurations)
public void registerCorsConfiguration(String path, CorsConfiguration config)
CorsConfiguration
for the specified path pattern.@Nullable public CorsConfiguration getCorsConfiguration(ServerWebExchange exchange)
CorsConfigurationSource
CorsConfiguration
based on the incoming request.getCorsConfiguration
in interface CorsConfigurationSource
CorsConfiguration
, or null
if none