HandlerFunction.
Access to headers and body is offered by Headers and
body(BodyExtractor), respectively.
| Modifier and Type | Class and Description |
|---|---|
| public static interface | ServerRequest.
Defines a builder for a request. |
| public static interface | ServerRequest.
Represents the headers of the HTTP request. |
| Modifier and Type | Method and Description |
|---|---|
| public default Optional | |
| public Map | |
| public default < the type to bind to T> Mono | Returns: a mono containing either a constructed and bound instance ofbindType, or a BindException in case of binding errorsthe type of class to bind this request to bindType)Bind to this request and return an instance of the given type. |
| public < the type to bind to T> Mono | Returns: a mono containing either a constructed and bound instance ofbindType, or a BindException in case of binding errorsthe type of class to bind this request to bindType, Consumer<WebDataBinder> used to customize the data binder, e.g. set
(dis)allowed fields dataBinderCustomizer)Bind to this request and return an instance of the given type. |
| public < the type of the body returned T> T | Returns: the extracted bodythe extractor)BodyExtractor that reads from the requestExtract the body with the given |
| public < the type of the body returned T> T | Returns: the extracted bodythe extractor, Map<String, Object> BodyExtractor that reads from the requestthe map of hints like hints)Jackson2CodecSupport#JSON_VIEW_HINT
to use to customize body extractionExtract the body with the given |
| public < the element type T> Flux | Returns: the body as a fluxthe class of element in the elementClass)FluxExtract the body to a |
| public < the element type T> Flux | Returns: a flux containing the body of the given typeTa type reference describing the expected request body type typeReference)Extract the body to a |
| public < the element type T> Mono | Returns: the body as a monothe class of element in the elementClass)MonoExtract the body to a |
| public < the element type T> Mono | Returns: a mono containing the body of the given typeTa type reference describing the expected response request type typeReference)Extract the body to a |
| public default Mono | Returns: a corresponding response if the request qualifies as not modified, or an empty result otherwisethe last-modified timestamp that the
application determined for the underlying resource lastModified)Check whether the requested resource has been modified given the supplied last-modified timestamp (as determined by the application). |
| public default Mono | Returns: a corresponding response if the request qualifies as not modified, or an empty result otherwisethe entity tag that the application determined
for the underlying resource. This parameter will be padded
with quotes (") if necessary. Use an empty string etag)""
for no value.Check whether the requested resource has been modified given the
supplied |
| public default Mono | Returns: a corresponding response if the request qualifies as not modified, or an empty result otherwise.the last-modified timestamp that the
application determined for the underlying resource lastModified, String the entity tag that the application determined
for the underlying resource. This parameter will be padded
with quotes (") if necessary. Use an empty string etag)""
for no value.Check whether the requested resource has been modified given the
supplied |
| public MultiValueMap | |
| public static ServerRequest | Returns: the createdServerRequestthe exchange exchange, List<HttpMessageReader<?>> the message readers messageReaders)Create a new |
| public ServerWebExchange | |
| public Mono | formData()
Get the form data from the body of the request if the Content-Type is
|
| public static ServerRequest. | Returns: the created builderthe request to copy the message readers, method name, URI,
headers, and attributes from other)Create a builder with the message readers, method name, URI, headers, cookies, and attributes of the given request. |
| public ServerRequest. | |
| public Optional | |
| public List | |
| public HttpMethod | |
| public String | Returns: the HTTP method as a String
Deprecated
since 6.0. as of 6.0, in favor of
method()
Get the name of the HTTP method. |
| public Mono | multipartData()
Get the parts of a multipart request if the Content-Type is
|
| public default String | |
| public default PathContainer | pathContainer()
Deprecated
as of 5.3, in favor on
requestPath()
Get the request path as a |
| public default String | Returns: the variable valuethe variable name name)Get the path variable with the given name, if present. |
| public Map | |
| public Mono | |
| public default Optional | Returns: the parameter valuethe parameter name name)Get the first query parameter with the given name, if present. |
| public MultiValueMap | |
| public Optional | |
| public default RequestPath | |
| public Mono | |
| public URI | |
| public UriBuilder | Returns: a URI builderGet a |
| attribute | back to summary |
|---|---|
| public default Optional Get the request attribute value if present. | |
| attributes | back to summary |
|---|---|
| public Map Get a mutable map of request attributes. | |
| bind | back to summary |
|---|---|
| public default <T> Mono Bind to this request and return an instance of the given type.
| |
| bind | back to summary |
|---|---|
| public <T> Mono Bind to this request and return an instance of the given type.
| |
| body | back to summary |
|---|---|
| public <T> T body(BodyExtractor<T, ? super ServerHttpRequest> extractor) Extract the body with the given
| |
| body | back to summary |
|---|---|
| public <T> T body(BodyExtractor<T, ? super ServerHttpRequest> extractor, Map<String, Object> hints) Extract the body with the given
| |
| bodyToFlux | back to summary |
|---|---|
| public <T> Flux Extract the body to a | |
| bodyToFlux | back to summary |
|---|---|
| public <T> Flux Extract the body to a
| |
| bodyToMono | back to summary |
|---|---|
| public <T> Mono Extract the body to a | |
| bodyToMono | back to summary |
|---|---|
| public <T> Mono Extract the body to a
| |
| checkNotModified | back to summary |
|---|---|
| public default Mono Check whether the requested resource has been modified given the supplied last-modified timestamp (as determined by the application). If not modified, this method returns a response with corresponding status code and headers, otherwise an empty result. Typical usage:
public Mono<ServerResponse> myHandleMethod(ServerRequest request) {
Instant lastModified = // application-specific calculation
return request.checkNotModified(lastModified)
.switchIfEmpty(Mono.defer(() -> {
// further request processing, actually building content
return ServerResponse.ok().body(...);
}));
}
This method works with conditional GET/HEAD requests, but also with conditional POST/PUT/DELETE requests. Note you can use either
this
| |
| checkNotModified | back to summary |
|---|---|
| public default Mono Check whether the requested resource has been modified given the
supplied If not modified, this method returns a response with corresponding status code and headers, otherwise an empty result. Typical usage:
public Mono<ServerResponse> myHandleMethod(ServerRequest request) {
String eTag = // application-specific calculation
return request.checkNotModified(eTag)
.switchIfEmpty(Mono.defer(() -> {
// further request processing, actually building content
return ServerResponse.ok().body(...);
}));
}
This method works with conditional GET/HEAD requests, but also with conditional POST/PUT/DELETE requests. Note you can use either
this
| |
| checkNotModified | back to summary |
|---|---|
| public default Mono Check whether the requested resource has been modified given the
supplied If not modified, this method returns a response with corresponding status code and headers, otherwise an empty result. Typical usage:
public Mono<ServerResponse> myHandleMethod(ServerRequest request) {
Instant lastModified = // application-specific calculation
String eTag = // application-specific calculation
return request.checkNotModified(lastModified, eTag)
.switchIfEmpty(Mono.defer(() -> {
// further request processing, actually building content
return ServerResponse.ok().body(...);
}));
}
This method works with conditional GET/HEAD requests, but also with conditional POST/PUT/DELETE requests.
| |
| cookies | back to summary |
|---|---|
| public MultiValueMap Get the cookies of this request. | |
| create | back to summary |
|---|---|
| public static ServerRequest create(ServerWebExchange exchange, List<HttpMessageReader<?>> messageReaders) Create a new
| |
| exchange | back to summary |
|---|---|
| public ServerWebExchange exchange() Get the web exchange that this request is based on. Note Manipulating the exchange directly (instead of using the methods provided on
| |
| formData | back to summary |
|---|---|
| public Mono Get the form data from the body of the request if the Content-Type is
Note calling this method causes the request body to
be read and parsed in full, and the resulting | |
| from | back to summary |
|---|---|
| public static ServerRequest. Create a builder with the message readers, method name, URI, headers, cookies, and attributes of the given request.
| |
| headers | back to summary |
|---|---|
| public ServerRequest. Get the headers of this request. | |
| localAddress | back to summary |
|---|---|
| public Optional Get the local address to which this request is connected, if available.
| |
| messageReaders | back to summary |
|---|---|
| public List Get the readers used to convert the body of this request.
| |
| method | back to summary |
|---|---|
| public HttpMethod method() Get the HTTP method. | |
| methodName | back to summary |
|---|---|
| public String methodName()
Get the name of the HTTP method.
| |
| multipartData | back to summary |
|---|---|
| public Mono Get the parts of a multipart request if the Content-Type is
Note calling this method causes the request body to
be read and parsed in full, and the resulting | |
| path | back to summary |
|---|---|
| public default String path() Get the request path. | |
| pathContainer | back to summary |
|---|---|
| public default PathContainer pathContainer()
Deprecated as of 5.3, in favor on Get the request path as a
| |
| pathVariable | back to summary |
|---|---|
| public default String pathVariable(String name) Get the path variable with the given name, if present.
| |
| pathVariables | back to summary |
|---|---|
| public Map Get all path variables for this request. | |
| principal | back to summary |
|---|---|
| public Mono Get the authenticated user for the request, if any. | |
| queryParam | back to summary |
|---|---|
| public default Optional Get the first query parameter with the given name, if present. | |
| queryParams | back to summary |
|---|---|
| public MultiValueMap Get all query parameters for this request. | |
| remoteAddress | back to summary |
|---|---|
| public Optional Get the remote address to which this request is connected, if available.
| |
| requestPath | back to summary |
|---|---|
| public default RequestPath requestPath() Get the request path as a
| |
| session | back to summary |
|---|---|
| public Mono Get the web session for this request. Always guaranteed to return an instance either matching the session id requested by the client, or with a new session id either because the client did not specify one or because the underlying session had expired. Use of this method does not automatically create a session. | |
| uri | back to summary |
|---|---|
| public URI uri() Get the request URI. | |
| uriBuilder | back to summary |
|---|---|
| public UriBuilder uriBuilder() Get a Note as of 5.1 this method ignores
| |
| Modifier and Type | Method and Description |
|---|---|
| public ServerRequest. | |
| public ServerRequest. | Returns: this buildera function that consumes the attributes map attributesConsumer)Manipulate this request's attributes with the given consumer. |
| public ServerRequest. | |
| public ServerRequest. | |
| public ServerRequest | |
| public ServerRequest. | Returns: this builderthe new context path contextPath)Set the context path of the request. |
| public ServerRequest. | |
| public ServerRequest. | Returns: this buildera function that consumes the cookies map cookiesConsumer)Manipulate this request's cookies with the given consumer. |
| public ServerRequest. | |
| public ServerRequest. | Returns: this buildera function that consumes the headersConsumer)HttpHeadersManipulate this request's headers with the given consumer. |
| public ServerRequest. | |
| public ServerRequest. |
| attribute | back to summary |
|---|---|
| public ServerRequest. Add an attribute with the given name and value.
| |
| attributes | back to summary |
|---|---|
| public ServerRequest. Manipulate this request's attributes with the given consumer. The map provided to the consumer is "live", so that the consumer can be used
to overwrite existing attributes,
remove attributes, or use any of the other
| |
| body | back to summary |
|---|---|
| public ServerRequest. Set the body of the request. Calling this methods will release the existing body of the builder.
| |
| body | back to summary |
|---|---|
| public ServerRequest. Set the body of the request to the UTF-8 encoded bytes of the given string. Calling this methods will release the existing body of the builder.
| |
| build | back to summary |
|---|---|
| public ServerRequest build() Build the request.
| |
| contextPath | back to summary |
|---|---|
| public ServerRequest. Set the context path of the request.
| |
| cookie | back to summary |
|---|---|
| public ServerRequest. Add a cookie with the given name and value(s).
| |
| cookies | back to summary |
|---|---|
| public ServerRequest. Manipulate this request's cookies with the given consumer. The map provided to the consumer is "live", so that the consumer can be used to
overwrite existing cookies,
remove cookies, or use any of the other
| |
| header | back to summary |
|---|---|
| public ServerRequest. Add the given header value(s) under the given name.
| |
| headers | back to summary |
|---|---|
| public ServerRequest. Manipulate this request's headers with the given consumer. The headers provided to the consumer are "live", so that the consumer can be used to
overwrite existing header values,
remove values, or use any of the other
| |
| method | back to summary |
|---|---|
| public ServerRequest. Set the method of the request.
| |
| uri | back to summary |
|---|---|
| public ServerRequest. Set the URI of the request.
| |
ServerRequest#headers()
| Modifier and Type | Method and Description |
|---|---|
| public List | |
| public List | |
| public List | |
| public HttpHeaders | |
| public OptionalLong | |
| public Optional | |
| public default String | firstHeader(String
the header name headerName)Get the first header value, if any, for the header with the given name. |
| public List | |
| public InetSocketAddress | |
| public List |
| accept | back to summary |
|---|---|
| public List Get the list of acceptable media types, as specified by the Returns an empty list if the acceptable media types are unspecified. | |
| acceptCharset | back to summary |
|---|---|
| public List Get the list of acceptable charsets, as specified by the
| |
| acceptLanguage | back to summary |
|---|---|
| public List Get the list of acceptable languages, as specified by the
| |
| asHttpHeaders | back to summary |
|---|---|
| public HttpHeaders asHttpHeaders() Get the headers as an instance of | |
| contentLength | back to summary |
|---|---|
| public OptionalLong contentLength() Get the length of the body in bytes, as specified by the
| |
| contentType | back to summary |
|---|---|
| public Optional Get the media type of the body, as specified by the
| |
| firstHeader | back to summary |
|---|---|
| public default String firstHeader(String headerName) Get the first header value, if any, for the header with the given name. Returns | |
| header | back to summary |
|---|---|
| public List Get the header value(s), if any, for the header with the given name. Returns an empty list if no header values are found.
| |
| host | back to summary |
|---|---|
| public InetSocketAddress host() Get the value of the If the header value does not contain a port, the
port in the returned address will
be
| |
| range | back to summary |
|---|---|
| public List Get the value of the Returns an empty list when the range is unknown. | |