Class MockserverRequest
- All Implemented Interfaces:
serverRequest
serverRequest.- since:
- 5.0
- Author:
- Arjen Poutsma
-
Nested Class summary
Nested ClassesNested classes/interfaces inherited from interface serverRequest
serverRequest.Headers -
Method summary
Modifier and TypeMethodDescriptionReturn the configuredApiVersionstrategy, ornull.Get a mutable map of request attributes.<T> reactor.core.publisher.Mono<T> Bind to this request and return an instance of the given type.<T> reactor.core.publisher.Mono<T> bind(Class<T> bindType, Consumer<WebDataBinder> dataBinderCustomizer) Bind to this request and return an instance of the given type.<s> sbody(BodyExtractor<s, ? super serverHttpRequest> extractor) Extract the body with the givenBodyExtractor.<s> sbody(BodyExtractor<s, ? super serverHttpRequest> extractor, Map<string, Object> hints) Extract the body with the givenBodyExtractorand hints.<s> reactor.core.publisher.Flux<s> bodyToFlux(Class<? extends s> elementClass) Extract the body to aFlux.<s> reactor.core.publisher.Flux<s> bodyToFlux(ParameterizedTypeReference<s> typeReference) Extract the body to aFlux.<s> reactor.core.publisher.Mono<s> bodyToMono(Class<? extends s> elementClass) Extract the body to aMono.<s> reactor.core.publisher.Mono<s> bodyToMono(ParameterizedTypeReference<s> typeReference) Extract the body to aMono.static MockserverRequest.Builderbuilder() cookies()Get the cookies of this request.exchange()Get the web exchange that this request is based on.reactor.core.publisher.Mono<MultiValueMap<string, string>> formData()Get the form data from the body of the request if the Content-Type is"application/x-www-form-urlencoded"or an empty map otherwise.headers()Get the headers of this request.Get the local address to which this request is connected, if available.Get the readers used to convert the body of this request.method()Get the HTTP method.reactor.core.publisher.Mono<MultiValueMap<string, Part>> Get the parts of a multipart request if the Content-Type is"multipart/form-data"or an empty map otherwise.Get all path variables for this request.reactor.core.publisher.Mono<? extends Principal> Get the authenticated user for the request, if any.Get all query parameters for this request.Get the remote address to which this request is connected, if available.Get the request path as aPathContainer.reactor.core.publisher.Mono<Websession> session()Get the web session for this request.uri()Get the request URI.Get aUriBuilderComponentsfrom the URI associated with thisserverRequest.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, tostring, wait, wait, waitMethods inherited from interface serverRequest
attribute, checkNotModified, checkNotModified, checkNotModified, path, pathVariable, queryParam
-
Method Details
-
method
Description copied from interface: serverRequestGet the HTTP method.- specified by:
method in interface serverRequest
-
uri
Description copied from interface: serverRequestGet the request URI.- specified by:
uri in interface serverRequest
-
uriBuilder
Description copied from interface: serverRequestGet aUriBuilderComponentsfrom the URI associated with thisserverRequest.Note: as of 5.1 this method ignores
"Forwarded"and"X-Forwarded-*"headers that specify the client-originated address. Consider using theForwardedHeaderFilterto extract and use, or to discard such headers.- specified by:
uriBuilder in interface serverRequest- Returns:
- a URI builder
-
requestPath
Description copied from interface: serverRequestGet the request path as aPathContainer.- specified by:
requestPath in interface serverRequest
-
headers
Description copied from interface: serverRequestGet the headers of this request.- specified by:
headers in interface serverRequest
-
cookies
Description copied from interface: serverRequestGet the cookies of this request.- specified by:
cookies in interface serverRequest
-
remoteAddress
Description copied from interface: serverRequestGet the remote address to which this request is connected, if available.- specified by:
remoteAddress in interface serverRequest
-
localAddress
Description copied from interface: serverRequestGet the local address to which this request is connected, if available.- specified by:
localAddress in interface serverRequest
-
messageReaders
Description copied from interface: serverRequestGet the readers used to convert the body of this request.- specified by:
messageReaders in interface serverRequest
-
apiVersionstrategy
Description copied from interface: serverRequestReturn the configuredApiVersionstrategy, ornull.- specified by:
apiVersionstrategy in interface serverRequest
-
body
Description copied from interface: serverRequestExtract the body with the givenBodyExtractor.- specified by:
body in interface serverRequest- Type Parameters:
s- the type of the body returned- Parameters:
extractor- theBodyExtractorthat reads from the request- Returns:
- the extracted body
- see Also:
-
body
public <s> s body(BodyExtractor<s, ? super serverHttpRequest> extractor, Map<string, Object> hints) Description copied from interface: serverRequestExtract the body with the givenBodyExtractorand hints.- specified by:
body in interface serverRequest- Type Parameters:
s- the type of the body returned- Parameters:
extractor- theBodyExtractorthat reads from the requesthints- the map of hints likeJacksonCodecsupport.JsON_VIEW_HINTto use to customize body extraction- Returns:
- the extracted body
-
bodyToMono
public <s> reactor.core.publisher.Mono<s> bodyToMono(Class<? extends s> elementClass) Description copied from interface: serverRequestExtract the body to aMono.- specified by:
bodyToMono in interface serverRequest- Type Parameters:
s- the element type- Parameters:
elementClass- the class of element in theMono- Returns:
- the body as a mono
-
bodyToMono
public <s> reactor.core.publisher.Mono<s> bodyToMono(ParameterizedTypeReference<s> typeReference) Description copied from interface: serverRequestExtract the body to aMono.- specified by:
bodyToMono in interface serverRequest- Type Parameters:
s- the element type- Parameters:
typeReference- a type reference describing the expected response request type- Returns:
- a mono containing the body of the given type
T
-
bodyToFlux
public <s> reactor.core.publisher.Flux<s> bodyToFlux(Class<? extends s> elementClass) Description copied from interface: serverRequestExtract the body to aFlux.- specified by:
bodyToFlux in interface serverRequest- Type Parameters:
s- the element type- Parameters:
elementClass- the class of element in theFlux- Returns:
- the body as a flux
-
bodyToFlux
public <s> reactor.core.publisher.Flux<s> bodyToFlux(ParameterizedTypeReference<s> typeReference) Description copied from interface: serverRequestExtract the body to aFlux.- specified by:
bodyToFlux in interface serverRequest- Type Parameters:
s- the element type- Parameters:
typeReference- a type reference describing the expected request body type- Returns:
- a flux containing the body of the given type
T
-
bind
Description copied from interface: serverRequestBind to this request and return an instance of the given type.- specified by:
bind in interface serverRequest- Type Parameters:
T- the type to bind to- Parameters:
bindType- the type of class to bind this request to- Returns:
- a mono containing either a constructed and bound instance of
bindType, or aBindExceptionin case of binding errors
-
bind
public <T> reactor.core.publisher.Mono<T> bind(Class<T> bindType, Consumer<WebDataBinder> dataBinderCustomizer) Description copied from interface: serverRequestBind to this request and return an instance of the given type.- specified by:
bind in interface serverRequest- Type Parameters:
T- the type to bind to- Parameters:
bindType- the type of class to bind this request todataBinderCustomizer- used to customize the data binder, for example, set (dis)allowed fields- Returns:
- a mono containing either a constructed and bound instance of
bindType, or aBindExceptionin case of binding errors
-
attributes
Description copied from interface: serverRequestGet a mutable map of request attributes.- specified by:
attributes in interface serverRequest- Returns:
- the request attributes
-
queryParams
Description copied from interface: serverRequestGet all query parameters for this request.- specified by:
queryParams in interface serverRequest
-
pathVariables
Description copied from interface: serverRequestGet all path variables for this request.- specified by:
pathVariables in interface serverRequest
-
session
Description copied from interface: serverRequestGet 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.
- specified by:
session in interface serverRequest
-
principal
Description copied from interface: serverRequestGet the authenticated user for the request, if any.- specified by:
principal in interface serverRequest
-
formData
Description copied from interface: serverRequestGet the form data from the body of the request if the Content-Type is"application/x-www-form-urlencoded"or an empty map otherwise.Note: calling this method causes the request body to be read and parsed in full, and the resulting
MultiValueMapis cached so that this method is safe to call more than once.- specified by:
formData in interface serverRequest
-
multipartData
Description copied from interface: serverRequestGet the parts of a multipart request if the Content-Type is"multipart/form-data"or an empty map otherwise.Note: calling this method causes the request body to be read and parsed in full, and the resulting
MultiValueMapis cached so that this method is safe to call more than once.- specified by:
multipartData in interface serverRequest
-
exchange
Description copied from interface: serverRequestGet the web exchange that this request is based on.Note: Manipulating the exchange directly (instead of using the methods provided on
serverRequestandserverResponse) can lead to irregular results.- specified by:
exchange in interface serverRequest
-
builder
-