Interface ServerResponse
- All Known Subinterfaces:
 EntityResponse<T>,RenderingResponse
public interface ServerResponse
Represents a typed server-side HTTP response, as returned
 by a handler function or
 filter function.
- Since:
 - 5.0
 - Author:
 - Arjen Poutsma, Juergen Hoeller, Sebastien Deleuze
 
- 
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceDefines a builder that adds a body to the response.static interfaceDefines the context used during thewriteTo(ServerWebExchange, Context).static interfaceDefines a builder that adds headers to the response. - 
Method Summary
Modifier and TypeMethodDescriptionstatic ServerResponse.BodyBuilderaccepted()Create a builder with an 202 Accepted status.static ServerResponse.BodyBuilderCreate a builder with a 400 Bad Request status.cookies()Return the cookies of this response.static ServerResponse.BodyBuilderCreate a new builder with a 201 Created status and a location header set to the given URI.static reactor.core.publisher.Mono<ServerResponse>from(ErrorResponse response) Create aServerResponsefrom the givenErrorResponse.static ServerResponse.BodyBuilderfrom(ServerResponse other) Create a builder with the status code and headers of the given response.headers()Return the headers of this response.static ServerResponse.HeadersBuilder<?>Create a builder with a 204 No Content status.static ServerResponse.HeadersBuilder<?>notFound()Create a builder with a 404 Not Found status.static ServerResponse.BodyBuilderok()Create a builder with the status set to 200 OK.static ServerResponse.BodyBuilderpermanentRedirect(URI location) Create a builder with a 308 Permanent Redirect status and a location header set to the given URI.intDeprecated, for removal: This API element is subject to removal in a future version.static ServerResponse.BodyBuilderCreate a builder with a 303 See Other status and a location header set to the given URI.static ServerResponse.BodyBuilderstatus(int status) Create a builder with the given HTTP status.static ServerResponse.BodyBuilderstatus(HttpStatusCode status) Create a builder with the given HTTP status.Return the status code of this response.static ServerResponse.BodyBuildertemporaryRedirect(URI location) Create a builder with a 307 Temporary Redirect status and a location header set to the given URI.static ServerResponse.BodyBuilderCreate a builder with an 422 Unprocessable Entity status.reactor.core.publisher.Mono<Void>writeTo(ServerWebExchange exchange, ServerResponse.Context context) Write this response to the given web exchange. 
- 
Method Details
- 
statusCode
HttpStatusCode statusCode()Return the status code of this response.- Returns:
 - the status as an HttpStatusCode value
 
 - 
rawStatusCode
Deprecated, for removal: This API element is subject to removal in a future version.in favor ofstatusCode(), for removal in 7.0Return the status code of this response as integer.- Returns:
 - the status as an integer
 - Since:
 - 5.2
 
 - 
headers
HttpHeaders headers()Return the headers of this response. - 
cookies
MultiValueMap<String,ResponseCookie> cookies()Return the cookies of this response. - 
writeTo
reactor.core.publisher.Mono<Void> writeTo(ServerWebExchange exchange, ServerResponse.Context context) Write this response to the given web exchange.- Parameters:
 exchange- the web exchange to write tocontext- the context to use when writing- Returns:
 Mono<Void>to indicate when writing is complete
 - 
from
Create a builder with the status code and headers of the given response.- Parameters:
 other- the response to copy the status and headers from- Returns:
 - the created builder
 
 - 
from
Create aServerResponsefrom the givenErrorResponse.- Parameters:
 response- theErrorResponseto initialize from- Returns:
 Monowith the built response- Since:
 - 6.0
 
 - 
status
Create a builder with the given HTTP status.- Parameters:
 status- the response status- Returns:
 - the created builder
 
 - 
status
Create a builder with the given HTTP status.- Parameters:
 status- the response status- Returns:
 - the created builder
 - Since:
 - 5.0.3
 
 - 
ok
Create a builder with the status set to 200 OK.- Returns:
 - the created builder
 
 - 
created
Create a new builder with a 201 Created status and a location header set to the given URI.- Parameters:
 location- the location URI- Returns:
 - the created builder
 
 - 
accepted
Create a builder with an 202 Accepted status.- Returns:
 - the created builder
 
 - 
noContent
Create a builder with a 204 No Content status.- Returns:
 - the created builder
 
 - 
seeOther
Create a builder with a 303 See Other status and a location header set to the given URI.- Parameters:
 location- the location URI- Returns:
 - the created builder
 
 - 
temporaryRedirect
Create a builder with a 307 Temporary Redirect status and a location header set to the given URI.- Parameters:
 location- the location URI- Returns:
 - the created builder
 
 - 
permanentRedirect
Create a builder with a 308 Permanent Redirect status and a location header set to the given URI.- Parameters:
 location- the location URI- Returns:
 - the created builder
 
 - 
badRequest
Create a builder with a 400 Bad Request status.- Returns:
 - the created builder
 
 - 
notFound
Create a builder with a 404 Not Found status.- Returns:
 - the created builder
 
 - 
unprocessableEntity
Create a builder with an 422 Unprocessable Entity status.- Returns:
 - the created builder
 
 
 - 
 
statusCode(), for removal in 7.0