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> Optional<T> |
attribute(String name)
Return the request attribute value if present.
|
<T> T |
body(BodyExtractor<T,? super ServerHttpRequest> extractor)
Extract the body with the given
BodyExtractor . |
<T> reactor.core.publisher.Flux<T> |
bodyToFlux(Class<? extends T> elementClass)
Extract the body to a
Flux . |
<T> reactor.core.publisher.Mono<T> |
bodyToMono(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 String |
path()
Return the request path.
|
default String |
pathVariable(String name)
Return the path variable with the given name, if present.
|
Map<String,String> |
pathVariables()
Return all path variables.
|
default Optional<String> |
queryParam(String name)
Return the first query parameter with the given name, if present.
|
List<String> |
queryParams(String name)
Return all query parameter with the given name.
|
URI |
uri()
Return the request URI.
|
HttpMethod method()
URI uri()
default 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 request<T> reactor.core.publisher.Mono<T> bodyToMono(Class<? extends T> elementClass)
Mono
.T
- the element typeelementClass
- the class of element in the Mono
<T> reactor.core.publisher.Flux<T> bodyToFlux(Class<? extends T> elementClass)
Flux
.T
- the element typeelementClass
- the class of element in the Flux
<T> Optional<T> attribute(String name)
T
- the attribute typename
- the attribute namedefault Optional<String> queryParam(String name)
name
- the parameter nameList<String> queryParams(String name)
name
- the parameter namedefault String pathVariable(String name)
name
- the variable nameIllegalArgumentException
- if there is no path variable with the given name