Class RouterFunctionMapping
- All Implemented Interfaces:
Aware,BeanNameAware,InitializingBean,ApplicationContextAware,Ordered,HandlerMapping
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.web.reactive.handler.AbstractHandlerMapping
mappingsLoggerFields inherited from class org.springframework.context.support.ApplicationObjectSupport
loggerFields 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_ATTRIBUTEFields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Constructor Summary
ConstructorsConstructorDescriptionCreate an emptyRouterFunctionMapping.RouterFunctionMapping(RouterFunction<?> routerFunction) Create aRouterFunctionMappingwith the givenRouterFunction. -
Method Summary
Modifier and TypeMethodDescriptionvoidInvoked by the containingBeanFactoryafter it has set all bean properties and satisfiedBeanFactoryAware,ApplicationContextAwareetc.protected reactor.core.publisher.Mono<?>getHandlerInternal(ServerWebExchange exchange) Look up a handler for the given request, returning an emptyMonoif no specific one is found.Return the configuredRouterFunction.protected voidInitialized the router functions by detecting them in the application context.voidsetMessageReaders(List<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, setUseTrailingSlashMatchMethods inherited from class org.springframework.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, initApplicationContext, initApplicationContext, isContextRequired, obtainApplicationContext, requiredContextClass, setApplicationContext
-
Constructor Details
-
RouterFunctionMapping
public RouterFunctionMapping()Create an emptyRouterFunctionMapping.If this constructor is used, this mapping will detect all
RouterFunctioninstances available in the application context. -
RouterFunctionMapping
Create aRouterFunctionMappingwith the givenRouterFunction.If this constructor is used, no application context detection will occur.
- Parameters:
routerFunction- the router function to use for mapping
-
-
Method Details
-
getRouterFunction
Return the configuredRouterFunction.Note: When router functions are detected from the ApplicationContext, this method may return
nullif invoked prior toafterPropertiesSet().- Returns:
- the router function or
null
-
setMessageReaders
Configure HTTP message readers to de-serialize the request body with.By default this is set to the
ServerCodecConfigurer's defaults. -
afterPropertiesSet
Description copied from interface:InitializingBeanInvoked by the containingBeanFactoryafter it has set all bean properties and satisfiedBeanFactoryAware,ApplicationContextAwareetc.This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set.
- Specified by:
afterPropertiesSetin interfaceInitializingBean- Throws:
Exception- in the event of misconfiguration (such as failure to set an essential property) or if initialization fails for any other reason
-
initRouterFunctions
protected void initRouterFunctions()Initialized the router functions by detecting them in the application context. -
getHandlerInternal
Description copied from class:AbstractHandlerMappingLook up a handler for the given request, returning an emptyMonoif no specific one is found. This method is called byAbstractHandlerMapping.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:
getHandlerInternalin classAbstractHandlerMapping- Parameters:
exchange- current exchange- Returns:
Monofor the matching handler, if any
-