class DefaultServerRequest extends java.lang.Object implements ServerRequest
ServerRequest
implementation based on a ServerWebExchange
.Modifier and Type | Class and Description |
---|---|
private class |
DefaultServerRequest.DefaultHeaders |
private class |
DefaultServerRequest.ServerRequestAdapter |
ServerRequest.Headers
Modifier and Type | Field and Description |
---|---|
private static java.util.function.Function<UnsupportedMediaTypeException,UnsupportedMediaTypeStatusException> |
ERROR_MAPPER |
private ServerWebExchange |
exchange |
private ServerRequest.Headers |
headers |
private java.util.List<HttpMessageReader<?>> |
messageReaders |
Constructor and Description |
---|
DefaultServerRequest(ServerWebExchange exchange,
java.util.List<HttpMessageReader<?>> messageReaders) |
Modifier and Type | Method and Description |
---|---|
java.util.Map<java.lang.String,java.lang.Object> |
attributes()
Return a mutable map of request attributes.
|
<T> T |
body(BodyExtractor<T,? super ServerHttpRequest> extractor)
Extract the body with the given
BodyExtractor . |
<T> T |
body(BodyExtractor<T,? super ServerHttpRequest> extractor,
java.util.Map<java.lang.String,java.lang.Object> hints)
Extract the body with the given
BodyExtractor and hints. |
<T> <any> |
bodyToFlux(java.lang.Class<? extends T> elementClass)
Extract the body to a
Flux . |
<T> <any> |
bodyToFlux(ParameterizedTypeReference<T> typeReference)
Extract the body to a
Flux . |
<T> <any> |
bodyToMono(java.lang.Class<? extends T> elementClass)
Extract the body to a
Mono . |
<T> <any> |
bodyToMono(ParameterizedTypeReference<T> typeReference)
Extract the body to a
Mono . |
MultiValueMap<java.lang.String,HttpCookie> |
cookies()
Return the cookies of this request.
|
(package private) ServerWebExchange |
exchange() |
ServerRequest.Headers |
headers()
Return the headers of this request.
|
java.lang.String |
methodName()
Return the name of the HTTP method.
|
PathContainer |
pathContainer()
Return the request path as
PathContainer . |
java.util.Map<java.lang.String,java.lang.String> |
pathVariables()
Return all path variables for this request.
|
<any> |
principal()
Return the authenticated user for the request, if any.
|
MultiValueMap<java.lang.String,java.lang.String> |
queryParams()
Return all query parameters for this request.
|
private ServerHttpRequest |
request() |
<any> |
session()
Return the web session for this request.
|
java.lang.String |
toString() |
private static <T> java.util.List<T> |
unmodifiableCopy(java.util.List<? extends T> list) |
java.net.URI |
uri()
Return the request URI.
|
UriBuilder |
uriBuilder()
Return a
UriBuilderComponents from the URI associated with this
ServerRequest , while also overlaying with values from the headers
"Forwarded" (RFC 7239),
or "X-Forwarded-Host", "X-Forwarded-Port", and "X-Forwarded-Proto" if
"Forwarded" is not found. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
attribute, create, method, path, pathVariable, queryParam
private static final java.util.function.Function<UnsupportedMediaTypeException,UnsupportedMediaTypeStatusException> ERROR_MAPPER
private final ServerWebExchange exchange
private final ServerRequest.Headers headers
private final java.util.List<HttpMessageReader<?>> messageReaders
DefaultServerRequest(ServerWebExchange exchange, java.util.List<HttpMessageReader<?>> messageReaders)
private static <T> java.util.List<T> unmodifiableCopy(java.util.List<? extends T> list)
public java.lang.String methodName()
ServerRequest
methodName
in interface ServerRequest
public java.net.URI uri()
ServerRequest
uri
in interface ServerRequest
public UriBuilder uriBuilder()
ServerRequest
UriBuilderComponents
from the URI associated with this
ServerRequest
, while also overlaying with values from the headers
"Forwarded" (RFC 7239),
or "X-Forwarded-Host", "X-Forwarded-Port", and "X-Forwarded-Proto" if
"Forwarded" is not found.uriBuilder
in interface ServerRequest
public PathContainer pathContainer()
ServerRequest
PathContainer
.pathContainer
in interface ServerRequest
public ServerRequest.Headers headers()
ServerRequest
headers
in interface ServerRequest
public MultiValueMap<java.lang.String,HttpCookie> cookies()
ServerRequest
cookies
in interface ServerRequest
public <T> T body(BodyExtractor<T,? super ServerHttpRequest> extractor)
ServerRequest
BodyExtractor
.body
in interface ServerRequest
T
- the type of the body returnedextractor
- the BodyExtractor
that reads from the requestServerRequest.body(BodyExtractor, Map)
public <T> T body(BodyExtractor<T,? super ServerHttpRequest> extractor, java.util.Map<java.lang.String,java.lang.Object> hints)
ServerRequest
BodyExtractor
and hints.body
in interface ServerRequest
T
- the type of the body returnedextractor
- the BodyExtractor
that reads from the requesthints
- the map of hints like Jackson2CodecSupport.JSON_VIEW_HINT
to use to customize body extractionpublic <T> <any> bodyToMono(java.lang.Class<? extends T> elementClass)
ServerRequest
Mono
.bodyToMono
in interface ServerRequest
T
- the element typeelementClass
- the class of element in the Mono
public <T> <any> bodyToMono(ParameterizedTypeReference<T> typeReference)
ServerRequest
Mono
.bodyToMono
in interface ServerRequest
T
- the element typetypeReference
- a type reference describing the expected response request typeT
public <T> <any> bodyToFlux(java.lang.Class<? extends T> elementClass)
ServerRequest
Flux
.bodyToFlux
in interface ServerRequest
T
- the element typeelementClass
- the class of element in the Flux
public <T> <any> bodyToFlux(ParameterizedTypeReference<T> typeReference)
ServerRequest
Flux
.bodyToFlux
in interface ServerRequest
T
- the element typetypeReference
- a type reference describing the expected request body typeT
public java.util.Map<java.lang.String,java.lang.Object> attributes()
ServerRequest
attributes
in interface ServerRequest
public MultiValueMap<java.lang.String,java.lang.String> queryParams()
ServerRequest
queryParams
in interface ServerRequest
public java.util.Map<java.lang.String,java.lang.String> pathVariables()
ServerRequest
pathVariables
in interface ServerRequest
public <any> session()
ServerRequest
session
in interface ServerRequest
public <any> principal()
ServerRequest
principal
in interface ServerRequest
private ServerHttpRequest request()
ServerWebExchange exchange()
public java.lang.String toString()
toString
in class java.lang.Object