public class RouterFunctionMapping extends AbstractHandlerMapping implements 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.
Modifier and Type | Field and Description |
---|---|
private java.util.List<HttpMessageReader<?>> |
messageReaders |
private RouterFunction<?> |
routerFunction |
logger
BEST_MATCHING_HANDLER_ATTRIBUTE, BEST_MATCHING_PATTERN_ATTRIBUTE, MATRIX_VARIABLES_ATTRIBUTE, PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE, PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE, URI_TEMPLATE_VARIABLES_ATTRIBUTE
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
Constructor and Description |
---|
RouterFunctionMapping()
Create an empty
RouterFunctionMapping . |
RouterFunctionMapping(RouterFunction<?> routerFunction)
Create a
RouterFunctionMapping with the given RouterFunction . |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet()
Invoked by the containing
BeanFactory after it has set all bean properties
and satisfied BeanFactoryAware , ApplicationContextAware etc. |
protected <any> |
getHandlerInternal(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.
|
private void |
logRouterFunctions(java.util.List<RouterFunction<?>> routerFunctions) |
private java.util.List<RouterFunction<?>> |
routerFunctions() |
private void |
setAttributes(java.util.Map<java.lang.String,java.lang.Object> attributes,
ServerRequest serverRequest,
HandlerFunction<?> handlerFunction) |
void |
setMessageReaders(java.util.List<HttpMessageReader<?>> messageReaders)
Configure HTTP message readers to de-serialize the request body with.
|
formatMappingName, getCorsConfiguration, getCorsProcessor, getHandler, getOrder, getPathPatternParser, hasCorsConfigurationSource, setBeanName, setCorsConfigurations, setCorsConfigurationSource, setCorsProcessor, setOrder, setUseCaseSensitiveMatch, setUseTrailingSlashMatch
getApplicationContext, getMessageSourceAccessor, initApplicationContext, initApplicationContext, isContextRequired, obtainApplicationContext, requiredContextClass, setApplicationContext
@Nullable private RouterFunction<?> routerFunction
private java.util.List<HttpMessageReader<?>> messageReaders
public RouterFunctionMapping()
RouterFunctionMapping
.
If this constructor is used, this mapping will detect all RouterFunction
instances
available in the application context.
public RouterFunctionMapping(RouterFunction<?> routerFunction)
RouterFunctionMapping
with the given RouterFunction
.
If this constructor is used, no application context detection will occur.
routerFunction
- the router function to use for mapping@Nullable public RouterFunction<?> getRouterFunction()
RouterFunction
.
Note: When router functions are detected from the
ApplicationContext, this method may return null
if invoked
prior to afterPropertiesSet()
.
null
public void setMessageReaders(java.util.List<HttpMessageReader<?>> messageReaders)
By default this is set to the ServerCodecConfigurer
's defaults.
public void afterPropertiesSet() throws java.lang.Exception
InitializingBean
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.
afterPropertiesSet
in interface InitializingBean
java.lang.Exception
- in the event of misconfiguration (such as failure to set an
essential property) or if initialization fails for any other reasonprotected void initRouterFunctions()
private java.util.List<RouterFunction<?>> routerFunctions()
private void logRouterFunctions(java.util.List<RouterFunction<?>> routerFunctions)
protected <any> getHandlerInternal(ServerWebExchange exchange)
AbstractHandlerMapping
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.
getHandlerInternal
in class AbstractHandlerMapping
exchange
- current exchangeMono
for the matching handler, if anyprivate void setAttributes(java.util.Map<java.lang.String,java.lang.Object> attributes, ServerRequest serverRequest, HandlerFunction<?> handlerFunction)