Package org.springframework.web.cors.reactive

# Class UrlBasedCorsConfigurationSource

java.lang.Object
org.springframework.web.cors.reactive.UrlBasedCorsConfigurationSource

All Implemented Interfaces:
  `CorsConfigurationSource`

public class UrlBasedCorsConfigurationSource extends Object implements CorsConfigurationSource
`CorsConfigurationSource` that uses URL patterns to select the `CorsConfiguration` for a request.

Since:
  5.0
Author:
  Sebastien Deleuze, Brian Clozel
See Also:
  - `PathPattern`

## Constructor Summary

Constructors
Constructor
Description
`UrlBasedCorsConfigurationSource()`
Construct a new `UrlBasedCorsConfigurationSource` instance with default `PathPatternParser`.
`UrlBasedCorsConfigurationSource(PathPatternParser patternParser)`
Construct a new `UrlBasedCorsConfigurationSource` instance from the supplied `PathPatternParser`.

## Method Summary

Modifier and Type
Method
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> configMap)`
Set CORS configuration based on URL patterns.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### UrlBasedCorsConfigurationSource

public UrlBasedCorsConfigurationSource()
Construct a new `UrlBasedCorsConfigurationSource` instance with default `PathPatternParser`.

Since:
  5.0.6

### UrlBasedCorsConfigurationSource

public UrlBasedCorsConfigurationSource(PathPatternParser patternParser)
Construct a new `UrlBasedCorsConfigurationSource` instance from the supplied `PathPatternParser`.

## Method Details

### setCorsConfigurations

public void setCorsConfigurations(@Nullable Map<String,CorsConfiguration> configMap)
Set CORS configuration based on URL patterns.

### registerCorsConfiguration

public void registerCorsConfiguration(String path, CorsConfiguration config)
Register a `CorsConfiguration` for the specified path pattern.

### getCorsConfiguration

@Nullable public CorsConfiguration getCorsConfiguration(ServerWebExchange exchange)
Description copied from interface: `CorsConfigurationSource`
Return a `CorsConfiguration` based on the incoming request.

Specified by:
  `getCorsConfiguration` in interface `CorsConfigurationSource`
Returns:
  the associated `CorsConfiguration`, or `null` if none