Class AbstractHandlerMapping
- All Implemented Interfaces:
org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanNameAware,org.springframework.context.ApplicationContextAware,org.springframework.core.Ordered,HandlerMapping
- Direct Known Subclasses:
AbstractHandlerMethodMapping,AbstractUrlHandlerMapping,RouterFunctionMapping
HandlerMapping
implementations.- Since:
- 5.0
- Author:
- Rossen Stoyanchev, Juergen Hoeller, Brian Clozel
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final org.apache.commons.logging.LogDedicated "hidden" logger for request mappings.Fields 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Stringprotected org.springframework.web.cors.CorsConfigurationgetCorsConfiguration(Object handler, org.springframework.web.server.ServerWebExchange exchange) Retrieve the CORS configuration for the given handler.org.springframework.web.cors.reactive.CorsProcessorReturn the configuredCorsProcessor.reactor.core.publisher.Mono<Object>getHandler(org.springframework.web.server.ServerWebExchange exchange) Return a handler for this request.protected abstract reactor.core.publisher.Mono<?>getHandlerInternal(org.springframework.web.server.ServerWebExchange exchange) Look up a handler for the given request, returning an emptyMonoif no specific one is found.intgetOrder()org.springframework.web.util.pattern.PathPatternParserReturn thePathPatternParserinstance that is used forCORS configuration checks.protected booleanhasCorsConfigurationSource(Object handler) Returntrueif there is aCorsConfigurationSourcefor this handler.voidsetBeanName(String name) voidsetCorsConfigurations(Map<String, org.springframework.web.cors.CorsConfiguration> corsConfigurations) Set the "global" CORS configurations based on URL patterns.voidsetCorsConfigurationSource(org.springframework.web.cors.reactive.CorsConfigurationSource corsConfigurationSource) Set the "global" CORS configuration source.voidsetCorsProcessor(org.springframework.web.cors.reactive.CorsProcessor corsProcessor) Configure a customCorsProcessorto use to apply the matchedCorsConfigurationfor a request.voidsetOrder(int order) Specify the order value for this HandlerMapping bean.voidsetUseCaseSensitiveMatch(boolean caseSensitiveMatch) Shortcut method for setting the same property on the underlying pattern parser in use.voidsetUseTrailingSlashMatch(boolean trailingSlashMatch) Deprecated.Methods inherited from class org.springframework.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, initApplicationContext, initApplicationContext, isContextRequired, obtainApplicationContext, requiredContextClass, setApplicationContext
-
Field Details
-
mappingsLogger
protected final org.apache.commons.logging.Log mappingsLoggerDedicated "hidden" logger for request mappings.
-
-
Constructor Details
-
AbstractHandlerMapping
public AbstractHandlerMapping()
-
-
Method Details
-
setUseCaseSensitiveMatch
public void setUseCaseSensitiveMatch(boolean caseSensitiveMatch) Shortcut method for setting the same property on the underlying pattern parser in use. For more details see:getPathPatternParser()-- the underlying pattern parserPathPatternParser.setCaseSensitive(boolean)-- the case sensitive slash option, including its default value.
Note: aside from
-
setUseTrailingSlashMatch
Deprecated.as of 6.0, seePathPatternParser.setMatchOptionalTrailingSeparator(boolean)Shortcut method for setting the same property on the underlying pattern parser in use. For more details see:getPathPatternParser()-- the underlying pattern parserPathPatternParser.setMatchOptionalTrailingSeparator(boolean)-- the trailing slash option, including its default value.
The default was changed in 6.0 from
truetofalsein order to support the deprecation of the property. -
getPathPatternParser
public org.springframework.web.util.pattern.PathPatternParser getPathPatternParser()Return thePathPatternParserinstance that is used forCORS configuration checks. Subclasses can also use this pattern parser for their own request mapping purposes. -
setCorsConfigurations
public void setCorsConfigurations(Map<String, org.springframework.web.cors.CorsConfiguration> corsConfigurations) Set the "global" CORS configurations based on URL patterns. By default, the first matching URL pattern is combined with handler-level CORS configuration if any. -
setCorsConfigurationSource
public void setCorsConfigurationSource(org.springframework.web.cors.reactive.CorsConfigurationSource corsConfigurationSource) Set the "global" CORS configuration source. By default, the first matching URL pattern is combined with the CORS configuration for the handler, if any.- Since:
- 5.1
- See Also:
-
setCorsProcessor
public void setCorsProcessor(org.springframework.web.cors.reactive.CorsProcessor corsProcessor) Configure a customCorsProcessorto use to apply the matchedCorsConfigurationfor a request.By default an instance of
DefaultCorsProcessoris used. -
getCorsProcessor
public org.springframework.web.cors.reactive.CorsProcessor getCorsProcessor()Return the configuredCorsProcessor. -
setOrder
public void setOrder(int order) Specify the order value for this HandlerMapping bean.The default value is
Ordered.LOWEST_PRECEDENCE, meaning non-ordered.- See Also:
-
Ordered.getOrder()
-
getOrder
public int getOrder()- Specified by:
getOrderin interfaceorg.springframework.core.Ordered
-
setBeanName
- Specified by:
setBeanNamein interfaceorg.springframework.beans.factory.BeanNameAware
-
formatMappingName
-
getHandler
public reactor.core.publisher.Mono<Object> getHandler(org.springframework.web.server.ServerWebExchange exchange) Description copied from interface:HandlerMappingReturn a handler for this request.Before returning a handler, an implementing method should check for CORS configuration associated with the handler, apply validation checks based on it, and update the response accordingly. For pre-flight requests, the same should be done based on the handler matching to the expected actual request.
- Specified by:
getHandlerin interfaceHandlerMapping- Parameters:
exchange- current server exchange- Returns:
- a
Monothat emits one value or none in case the request cannot be resolved to a handler
-
getHandlerInternal
protected abstract reactor.core.publisher.Mono<?> getHandlerInternal(org.springframework.web.server.ServerWebExchange exchange) Look up a handler for the given request, returning an emptyMonoif no specific one is found. This method is called bygetHandler(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.
- Parameters:
exchange- current exchange- Returns:
Monofor the matching handler, if any
-
hasCorsConfigurationSource
Returntrueif there is aCorsConfigurationSourcefor this handler.- Since:
- 5.2
-
getCorsConfiguration
@Nullable protected org.springframework.web.cors.CorsConfiguration getCorsConfiguration(Object handler, org.springframework.web.server.ServerWebExchange exchange) Retrieve the CORS configuration for the given handler.- Parameters:
handler- the handler to check (nevernull)exchange- the current exchange- Returns:
- the CORS configuration for the handler, or
nullif none
-
PathPatternParser.setMatchOptionalTrailingSeparator(boolean)