org.springframework.web.reactive.function.server.support

## Class RouterFunctionMapping

- java.lang.Object
- - org.springframework.context.support.ApplicationObjectSupport
  - - org.springframework.web.reactive.handler.AbstractHandlerMapping
    - - org.springframework.web.reactive.function.server.support.RouterFunctionMapping

All Implemented Interfaces:
  org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationContextAware, org.springframework.core.Ordered, HandlerMapping

    public class RouterFunctionMapping
    extends AbstractHandlerMapping
    implements org.springframework.beans.factory.InitializingBean

`HandlerMapping` implementation that supports `RouterFunctions`.

If no `RouterFunction` is provided at construction time, this mapping will detect all router functions in the application context, and consult them in order.

Since:
  5.0
Author:
  Arjen Poutsma

### Field Summary

### Fields inherited from class org.springframework.context.support.ApplicationObjectSupport

`logger`

### Fields inherited from interface org.springframework.web.reactive.HandlerMapping

`BEST_MATCHING_HANDLER_ATTRIBUTE, BEST_MATCHING_PATTERN_ATTRIBUTE, MATRIX_VARIABLES_ATTRIBUTE, PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE, PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE, URI_TEMPLATE_VARIABLES_ATTRIBUTE`

### Fields inherited from interface org.springframework.core.Ordered

`HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE`

### Constructor Summary

Constructors
Constructor and Description
`RouterFunctionMapping()` Create an empty `RouterFunctionMapping`.
`RouterFunctionMapping(RouterFunction<?> routerFunction)` Create a `RouterFunctionMapping` with the given `RouterFunction`.

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `afterPropertiesSet()`
`protected reactor.core.publisher.Mono<?>` `getHandlerInternal(org.springframework.web.server.ServerWebExchange exchange)` Look up a handler for the given request, returning an empty `Mono` if no specific one is found.
`RouterFunction<?>` `getRouterFunction()` Return the configured `RouterFunction`.
`protected void` `initRouterFunctions()` Initialized the router functions by detecting them in the application context.
`void` `setMessageReaders(List<org.springframework.http.codec.HttpMessageReader<?>> messageReaders)` Configure HTTP message readers to de-serialize the request body with.

### Methods inherited from class org.springframework.web.reactive.handler.AbstractHandlerMapping

`formatMappingName, getCorsConfiguration, getCorsProcessor, getHandler, getOrder, getPathPatternParser, hasCorsConfigurationSource, setBeanName, setCorsConfigurations, setCorsConfigurationSource, setCorsProcessor, setOrder, setUseCaseSensitiveMatch, setUseTrailingSlashMatch`

### Methods inherited from class org.springframework.context.support.ApplicationObjectSupport

`getApplicationContext, getMessageSourceAccessor, initApplicationContext, initApplicationContext, isContextRequired, obtainApplicationContext, requiredContextClass, setApplicationContext`

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

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

### Constructor Detail

#### RouterFunctionMapping

    public RouterFunctionMapping()

Create an empty `RouterFunctionMapping`.

If this constructor is used, this mapping will detect all `RouterFunction` instances available in the application context.

#### RouterFunctionMapping

    public RouterFunctionMapping(RouterFunction<?> routerFunction)

Create a `RouterFunctionMapping` with the given `RouterFunction`.

If this constructor is used, no application context detection will occur.

Parameters:
  `routerFunction` - the router function to use for mapping

### Method Detail

#### getRouterFunction

    @Nullable
    public RouterFunction<?> getRouterFunction()

Return the configured `RouterFunction`.

Note: When router functions are detected from the ApplicationContext, this method may return `null` if invoked prior to `afterPropertiesSet()`.

Returns:
  the router function or `null`

#### setMessageReaders

    public void setMessageReaders(List<org.springframework.http.codec.HttpMessageReader<?>> messageReaders)

Configure HTTP message readers to de-serialize the request body with.

By default this is set to the `ServerCodecConfigurer`'s defaults.

#### afterPropertiesSet

    public void afterPropertiesSet()
                            throws Exception

Specified by:
  `afterPropertiesSet` in interface `org.springframework.beans.factory.InitializingBean`
Throws:
  `Exception`

#### initRouterFunctions

    protected void initRouterFunctions()

Initialized the router functions by detecting them in the application context.

#### getHandlerInternal

    protected reactor.core.publisher.Mono<?> getHandlerInternal(org.springframework.web.server.ServerWebExchange exchange)

Description copied from class: `AbstractHandlerMapping`
Look up a handler for the given request, returning an empty `Mono` if no specific one is found. This method is called by `AbstractHandlerMapping.getHandler(org.springframework.web.server.ServerWebExchange)`.

On CORS pre-flight requests this method should return a match not for the pre-flight request but for the expected actual request based on the URL path, the HTTP methods from the "Access-Control-Request-Method" header, and the headers from the "Access-Control-Request-Headers" header.

Specified by:
  `getHandlerInternal` in class `AbstractHandlerMapping`
Parameters:
  `exchange` - current exchange
Returns:
  `Mono` for the matching handler, if any