public interface ServerRequest
HandlerFunction
.
Access to headers and body is offered by ServerRequest.Headers
and
body(BodyExtractor)
respectively.Modifier and Type | Interface and Description |
---|---|
static interface |
ServerRequest.Headers
Represents the headers of the HTTP request.
|
Modifier and Type | Method and Description |
---|---|
<T> java.util.Optional<T> |
attribute(java.lang.String name)
Return the request attribute value if present.
|
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> |
bodyToMono(java.lang.Class<? extends T> elementClass)
Extract the body to a
Mono . |
ServerRequest.Headers |
headers()
Return the headers of this request.
|
HttpMethod |
method()
Return the HTTP method.
|
default java.lang.String |
path()
Return the request path.
|
default java.lang.String |
pathVariable(java.lang.String name)
Return the path variable with the given name, if present.
|
java.util.Map<java.lang.String,java.lang.String> |
pathVariables()
Return all path variables.
|
default java.util.Optional<java.lang.String> |
queryParam(java.lang.String name)
Return the first query parameter with the given name, if present.
|
java.util.List<java.lang.String> |
queryParams(java.lang.String name)
Return all query parameter with the given name.
|
<any> |
session()
Return the web session for the current request.
|
java.net.URI |
uri()
Return the request URI.
|
HttpMethod method()
java.net.URI uri()
default java.lang.String path()
ServerRequest.Headers headers()
<T> T body(BodyExtractor<T,? super ServerHttpRequest> extractor)
BodyExtractor
.T
- the type of the body returnedextractor
- the BodyExtractor
that reads from the requestbody(BodyExtractor, Map)
<T> T body(BodyExtractor<T,? super ServerHttpRequest> extractor, java.util.Map<java.lang.String,java.lang.Object> hints)
BodyExtractor
and hints.T
- the type of the body returnedextractor
- the BodyExtractor
that reads from the requesthints
- the map of hints like AbstractJackson2Codec.JSON_VIEW_HINT
to use to customize body extraction<T> <any> bodyToMono(java.lang.Class<? extends T> elementClass)
Mono
.T
- the element typeelementClass
- the class of element in the Mono
<T> <any> bodyToFlux(java.lang.Class<? extends T> elementClass)
Flux
.T
- the element typeelementClass
- the class of element in the Flux
<T> java.util.Optional<T> attribute(java.lang.String name)
T
- the attribute typename
- the attribute namejava.util.Map<java.lang.String,java.lang.Object> attributes()
default java.util.Optional<java.lang.String> queryParam(java.lang.String name)
name
- the parameter namejava.util.List<java.lang.String> queryParams(java.lang.String name)
Returns an empty list if no values could be found.
name
- the parameter namedefault java.lang.String pathVariable(java.lang.String name)
name
- the variable namejava.lang.IllegalArgumentException
- if there is no path variable with the given namejava.util.Map<java.lang.String,java.lang.String> pathVariables()
<any> session()