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 and Description
    `UrlBasedCorsConfigurationSource()` Construct a new `UrlBasedCorsConfigurationSource` instance with default `PathPatternParser`.
    `UrlBasedCorsConfigurationSource(PathPatternParser patternParser)` Construct a new `UrlBasedCorsConfigurationSource` instance from the supplied `PathPatternParser`.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    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> 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 Detail

    - #### 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 Detail

    - #### 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