public class UrlBasedCorsConfigurationSource extends java.lang.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/**"
).
Modifier and Type | Field and Description |
---|---|
private java.util.Map<java.lang.String,CorsConfiguration> |
corsConfigurations |
private HttpRequestPathHelper |
pathHelper |
private PathMatcher |
pathMatcher |
Constructor and Description |
---|
UrlBasedCorsConfigurationSource() |
Modifier and Type | Method and Description |
---|---|
CorsConfiguration |
getCorsConfiguration(ServerWebExchange exchange)
Return a
CorsConfiguration based on the incoming request. |
java.util.Map<java.lang.String,CorsConfiguration> |
getCorsConfigurations()
Get the CORS configuration.
|
void |
registerCorsConfiguration(java.lang.String path,
CorsConfiguration config)
Register a
CorsConfiguration for the specified path pattern. |
void |
setCorsConfigurations(java.util.Map<java.lang.String,CorsConfiguration> corsConfigurations)
Set CORS configuration based on URL patterns.
|
void |
setHttpRequestPathHelper(HttpRequestPathHelper pathHelper)
Set the UrlPathHelper to use for resolution of lookup paths.
|
void |
setPathMatcher(PathMatcher pathMatcher)
Set the PathMatcher implementation to use for matching URL paths
against registered URL patterns.
|
void |
setUrlDecode(boolean urlDecode)
Set if context path and request URI should be URL-decoded.
|
private final java.util.Map<java.lang.String,CorsConfiguration> corsConfigurations
private PathMatcher pathMatcher
private HttpRequestPathHelper pathHelper
public void setPathMatcher(PathMatcher pathMatcher)
ParsingPathMatcher
public void setUrlDecode(boolean urlDecode)
Uses either the request encoding or the default encoding according to the Servlet spec (ISO-8859-1).
public void setHttpRequestPathHelper(HttpRequestPathHelper pathHelper)
Use this to override the default UrlPathHelper with a custom subclass.
public void setCorsConfigurations(java.util.Map<java.lang.String,CorsConfiguration> corsConfigurations)
public java.util.Map<java.lang.String,CorsConfiguration> getCorsConfigurations()
public void registerCorsConfiguration(java.lang.String path, CorsConfiguration config)
CorsConfiguration
for the specified path pattern.public CorsConfiguration getCorsConfiguration(ServerWebExchange exchange)
CorsConfigurationSource
CorsConfiguration
based on the incoming request.getCorsConfiguration
in interface CorsConfigurationSource
CorsConfiguration
, or null
if none