Class RequestHeaderMethodArgumentResolver
java.lang.Object
org.springframework.web.reactive.result.method.HandlerMethodArgumentResolverSupport
org.springframework.web.reactive.result.method.annotation.AbstractNamedValueArgumentResolver
org.springframework.web.reactive.result.method.annotation.AbstractNamedValueSyncArgumentResolver
org.springframework.web.reactive.result.method.annotation.RequestHeaderMethodArgumentResolver
- All Implemented Interfaces:
HandlerMethodArgumentResolver
,SyncHandlerMethodArgumentResolver
Resolves method arguments annotated with
@RequestHeader
except for
Map
arguments. See RequestHeaderMapMethodArgumentResolver
for
details on Map
arguments annotated with @RequestHeader
.
An @RequestHeader
is a named value resolved from a request header.
It has a required flag and a default value to fall back on when the request
header does not exist.
A ConversionService
is invoked to apply type conversion to resolved
request header values that don't yet match the method parameter type.
- Since:
- 5.0
- Author:
- Rossen Stoyanchev
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.springframework.web.reactive.result.method.annotation.AbstractNamedValueArgumentResolver
AbstractNamedValueArgumentResolver.NamedValueInfo
-
Field Summary
Fields inherited from class org.springframework.web.reactive.result.method.HandlerMethodArgumentResolverSupport
logger
-
Constructor Summary
ConstructorDescriptionRequestHeaderMethodArgumentResolver
(ConfigurableBeanFactory factory, ReactiveAdapterRegistry registry) Create a newRequestHeaderMethodArgumentResolver
instance. -
Method Summary
Modifier and TypeMethodDescriptioncreateNamedValueInfo
(MethodParameter parameter) Create theAbstractNamedValueArgumentResolver.NamedValueInfo
object for the given method parameter.protected void
handleMissingValue
(String name, MethodParameter parameter) Invoked when a named value is required, butAbstractNamedValueArgumentResolver.resolveName(String, MethodParameter, ServerWebExchange)
returnednull
and there is no default value.protected Object
resolveNamedValue
(String name, MethodParameter parameter, ServerWebExchange exchange) Actually resolve the value synchronously.boolean
supportsParameter
(MethodParameter param) Whether this resolver supports the given method parameter.Methods inherited from class org.springframework.web.reactive.result.method.annotation.AbstractNamedValueSyncArgumentResolver
resolveArgument, resolveArgumentValue, resolveName
Methods inherited from class org.springframework.web.reactive.result.method.annotation.AbstractNamedValueArgumentResolver
handleMissingValue, handleResolvedValue
Methods inherited from class org.springframework.web.reactive.result.method.HandlerMethodArgumentResolverSupport
checkAnnotatedParamNoReactiveWrapper, checkParameterType, checkParameterTypeNoReactiveWrapper, getAdapterRegistry
-
Constructor Details
-
RequestHeaderMethodArgumentResolver
public RequestHeaderMethodArgumentResolver(@Nullable ConfigurableBeanFactory factory, ReactiveAdapterRegistry registry) Create a newRequestHeaderMethodArgumentResolver
instance.- Parameters:
factory
- a bean factory to use for resolving${...}
placeholder and#{...}
SpEL expressions in default values; ornull
if default values are not expected to have expressionsregistry
- for checking reactive type wrappers
-
-
Method Details
-
supportsParameter
Description copied from interface:HandlerMethodArgumentResolver
Whether this resolver supports the given method parameter.- Parameters:
param
- the method parameter
-
createNamedValueInfo
protected AbstractNamedValueArgumentResolver.NamedValueInfo createNamedValueInfo(MethodParameter parameter) Description copied from class:AbstractNamedValueArgumentResolver
Create theAbstractNamedValueArgumentResolver.NamedValueInfo
object for the given method parameter. Implementations typically retrieve the method annotation by means ofMethodParameter.getParameterAnnotation(Class)
.- Specified by:
createNamedValueInfo
in classAbstractNamedValueArgumentResolver
- Parameters:
parameter
- the method parameter- Returns:
- the named value information
-
resolveNamedValue
@Nullable protected Object resolveNamedValue(String name, MethodParameter parameter, ServerWebExchange exchange) Description copied from class:AbstractNamedValueSyncArgumentResolver
Actually resolve the value synchronously.- Specified by:
resolveNamedValue
in classAbstractNamedValueSyncArgumentResolver
-
handleMissingValue
Description copied from class:AbstractNamedValueArgumentResolver
Invoked when a named value is required, butAbstractNamedValueArgumentResolver.resolveName(String, MethodParameter, ServerWebExchange)
returnednull
and there is no default value. Subclasses typically throw an exception in this case.- Overrides:
handleMissingValue
in classAbstractNamedValueArgumentResolver
- Parameters:
name
- the name for the valueparameter
- the method parameter
-