public abstract class AbstractHandlerMapping extends ApplicationObjectSupport implements HandlerMapping, Ordered
HandlerMapping
implementations.logger
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 |
---|
AbstractHandlerMapping() |
Modifier and Type | Method and Description |
---|---|
protected CorsConfiguration |
getCorsConfiguration(Object handler,
ServerWebExchange exchange)
Retrieve the CORS configuration for the given handler.
|
Map<String,CorsConfiguration> |
getCorsConfigurations()
Return the "global" CORS configuration.
|
CorsProcessor |
getCorsProcessor()
Return the configured
CorsProcessor . |
reactor.core.publisher.Mono<Object> |
getHandler(ServerWebExchange exchange)
Return a handler for this request.
|
protected abstract reactor.core.publisher.Mono<?> |
getHandlerInternal(ServerWebExchange exchange)
Look up a handler for the given request, returning an empty
Mono
if no specific one is found. |
int |
getOrder()
Get the order value of this object.
|
HttpRequestPathHelper |
getPathHelper()
Return the
HttpRequestPathHelper implementation to use for
resolution of lookup paths. |
PathMatcher |
getPathMatcher()
Return the PathMatcher implementation to use for matching URL paths
against registered URL patterns.
|
void |
setCorsConfigurations(Map<String,CorsConfiguration> corsConfigurations)
Set "global" CORS configuration based on URL patterns.
|
void |
setCorsProcessor(CorsProcessor corsProcessor)
Configure a custom
CorsProcessor to use to apply the matched
CorsConfiguration for a request. |
void |
setOrder(int order)
Specify the order value for this HandlerMapping bean.
|
void |
setPathHelper(HttpRequestPathHelper pathHelper)
Set the
HttpRequestPathHelper to use for resolution of lookup
paths. |
void |
setPathMatcher(PathMatcher pathMatcher)
Set the PathMatcher implementation to use for matching URL paths
against registered URL patterns.
|
void |
setUrlDecode(boolean urlDecode)
Set if the path should be URL-decoded.
|
getApplicationContext, getMessageSourceAccessor, initApplicationContext, initApplicationContext, isContextRequired, requiredContextClass, setApplicationContext
public final void setOrder(int order)
Default value is Integer.MAX_VALUE
, meaning that it's non-ordered.
Ordered.getOrder()
public final int getOrder()
Ordered
Higher values are interpreted as lower priority. As a consequence,
the object with the lowest value has the highest priority (somewhat
analogous to Servlet load-on-startup
values).
Same order values will result in arbitrary sort positions for the affected objects.
getOrder
in interface Ordered
Ordered.HIGHEST_PRECEDENCE
,
Ordered.LOWEST_PRECEDENCE
public void setUrlDecode(boolean urlDecode)
public void setPathHelper(HttpRequestPathHelper pathHelper)
HttpRequestPathHelper
to use for resolution of lookup
paths. Use this to override the default implementation with a custom
subclass or to share common path helper settings across multiple
HandlerMappings.public HttpRequestPathHelper getPathHelper()
HttpRequestPathHelper
implementation to use for
resolution of lookup paths.public void setPathMatcher(PathMatcher pathMatcher)
ParsingPathMatcher
public PathMatcher getPathMatcher()
public void setCorsConfigurations(Map<String,CorsConfiguration> corsConfigurations)
public Map<String,CorsConfiguration> getCorsConfigurations()
public void setCorsProcessor(CorsProcessor corsProcessor)
CorsProcessor
to use to apply the matched
CorsConfiguration
for a request.
By default an instance of DefaultCorsProcessor
is used.
public CorsProcessor getCorsProcessor()
CorsProcessor
.public reactor.core.publisher.Mono<Object> getHandler(ServerWebExchange exchange)
HandlerMapping
getHandler
in interface HandlerMapping
exchange
- current server exchangeMono
that emits one value or none in case the request
cannot be resolved to a handlerprotected abstract reactor.core.publisher.Mono<?> getHandlerInternal(ServerWebExchange exchange)
Mono
if no specific one is found. This method is called by 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 thus allowing
the CORS configuration to be obtained via getCorsConfigurations()
,
exchange
- current exchangeMono
for the matching handler, if anyprotected CorsConfiguration getCorsConfiguration(Object handler, ServerWebExchange exchange)
handler
- the handler to check (never null
)exchange
- the current exchangenull
if none