Top Description Fields Constructors Methods
org.springframework.web.reactive.function.server.support

public Class RouterFunctionMapping

extends AbstractHandlerMapping
implements InitializingBean
Class Inheritance
All Implemented Interfaces
org.springframework.beans.factory.InitializingBean
Imports
java.util.Collections, .List, .Map, java.util.stream.Collectors, reactor.core.publisher.Mono, org.springframework.beans.factory.InitializingBean, org.springframework.http.codec.HttpMessageReader, .ServerCodecConfigurer, org.springframework.http.server.reactive.observation.ServerRequestObservationContext, org.springframework.lang.Nullable, org.springframework.util.CollectionUtils, org.springframework.web.reactive.function.server.HandlerFunction, .RouterFunction, .RouterFunctions, .ServerRequest, org.springframework.web.reactive.handler.AbstractHandlerMapping, org.springframework.web.server.ServerWebExchange, org.springframework.web.util.pattern.PathPattern

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.

Author
Arjen Poutsma
Since
5.0

Field Summary

Modifier and TypeField and Description
private List<HttpMessageReader<?>>
private RouterFunction<?>
Inherited from org.springframework.web.reactive.handler.AbstractHandlerMapping:
mappingsLogger

Constructor Summary

AccessConstructor and Description
public
RouterFunctionMapping()

Create an empty RouterFunctionMapping.

public
RouterFunctionMapping(RouterFunction<?>
the router function to use for mapping
routerFunction
)

Create a RouterFunctionMapping with the given RouterFunction.

Method Summary

Modifier and TypeMethod and Description
public void
afterPropertiesSet()

Implements org.springframework.beans.factory.InitializingBean.afterPropertiesSet.

Invoked by the containing BeanFactory after it has set all bean properties and satisfied BeanFactoryAware, ApplicationContextAware etc.

This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set.

protected Mono<?>
getHandlerInternal(ServerWebExchange
current exchange
exchange
)

Implements abstract org.springframework.web.reactive.handler.AbstractHandlerMapping.getHandlerInternal.

Look up a handler for the given request, returning an empty Mono if no specific one is found.

public RouterFunction<?>

Returns:

the router function or null
getRouterFunction
()

Return the configured RouterFunction.

protected void
initRouterFunctions()

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

private void
logRouterFunctions(List<RouterFunction<?>> routerFunctions)

private List<RouterFunction<?>>
private void
setAttributes(Map<String, Object> attributes, ServerRequest serverRequest, HandlerFunction<?> handlerFunction)

public void
setMessageReaders(List<HttpMessageReader<?>> messageReaders)

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

Inherited from org.springframework.web.reactive.handler.AbstractHandlerMapping:
formatMappingNamegetCorsConfigurationgetCorsProcessorgetHandlergetOrdergetPathPatternParserhasCorsConfigurationSourcesetBeanNamesetCorsConfigurationssetCorsConfigurationSourcesetCorsProcessorsetOrdersetUseCaseSensitiveMatchsetUseTrailingSlashMatch

Field Detail

messageReadersback to summary
private List<HttpMessageReader<?>> messageReaders
routerFunctionback to summary
private RouterFunction<?> routerFunction
Annotations
@Nullable

Constructor Detail

RouterFunctionMappingback to summary
public RouterFunctionMapping()

Create an empty RouterFunctionMapping.

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

RouterFunctionMappingback to summary
public RouterFunctionMapping(RouterFunction<?> routerFunction)

Create a RouterFunctionMapping with the given RouterFunction.

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

Parameters
routerFunction:RouterFunction<?>

the router function to use for mapping

Method Detail

afterPropertiesSetback to summary
public void afterPropertiesSet() throws Exception

Implements org.springframework.beans.factory.InitializingBean.afterPropertiesSet.

Doc from org.springframework.beans.factory.InitializingBean.afterPropertiesSet.

Invoked by the containing BeanFactory after it has set all bean properties and satisfied BeanFactoryAware, ApplicationContextAware etc.

This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set.

Annotations
@Override
Exceptions
Exception:
in the event of misconfiguration (such as failure to set an essential property) or if initialization fails for any other reason
getHandlerInternalback to summary
protected Mono<?> getHandlerInternal(ServerWebExchange exchange)

Implements abstract org.springframework.web.reactive.handler.AbstractHandlerMapping.getHandlerInternal.

Doc from org.springframework.web.reactive.handler.AbstractHandlerMapping.getHandlerInternal.

Look up a handler for the given request, returning an empty Mono if no specific one is found. This method is called by getHandler.

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.

Parameters
exchange:ServerWebExchange

current exchange

Returns:Mono<?>

Mono for the matching handler, if any

Annotations
@Override
getRouterFunctionback to summary
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:RouterFunction<?>

the router function or null

Annotations
@Nullable
initRouterFunctionsback to summary
protected void initRouterFunctions()

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

logRouterFunctionsback to summary
private void logRouterFunctions(List<RouterFunction<?>> routerFunctions)
routerFunctionsback to summary
private List<RouterFunction<?>> routerFunctions()
setAttributesback to summary
private void setAttributes(Map<String, Object> attributes, ServerRequest serverRequest, HandlerFunction<?> handlerFunction)
Annotations
@SuppressWarnings:unchecked, removal
setMessageReadersback to summary
public void setMessageReaders(List<HttpMessageReader<?>> messageReaders)

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

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