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
  • Method Details

    • statusCode

      org.springframework.http.HttpStatusCode statusCode()
      Return the status code of this response.
      Returns:
      the status as an HttpStatusCode value
    • rawStatusCode

      @Deprecated(since="6.0") int rawStatusCode()
      Deprecated.
      as of 6.0, in favor of statusCode()
      Return the status code of this response as integer.
      Returns:
      the status as an integer
      Since:
      5.2
    • headers

      org.springframework.http.HttpHeaders headers()
      Return the headers of this response.
    • cookies

      org.springframework.util.MultiValueMap<String,org.springframework.http.ResponseCookie> cookies()
      Return the cookies of this response.
    • writeTo

      reactor.core.publisher.Mono<Void> writeTo(org.springframework.web.server.ServerWebExchange exchange, ServerResponse.Context context)
      Write this response to the given web exchange.
      Parameters:
      exchange - the web exchange to write to
      context - 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

      static reactor.core.publisher.Mono<ServerResponse> from(org.springframework.web.ErrorResponse response)
      Create a ServerResponse from the given ErrorResponse.
      Parameters:
      response - the ErrorResponse to initialize from
      Returns:
      Mono with the built response
      Since:
      6.0
    • status

      static ServerResponse.BodyBuilder status(org.springframework.http.HttpStatusCode status)
      Create a builder with the given HTTP status.
      Parameters:
      status - the response status
      Returns:
      the created builder
    • status

      static ServerResponse.BodyBuilder status(int 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

      static ServerResponse.BodyBuilder created(URI location)
      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

      static ServerResponse.BodyBuilder accepted()
      Create a builder with an 202 Accepted status.
      Returns:
      the created builder
    • noContent

      static ServerResponse.HeadersBuilder<?> noContent()
      Create a builder with a 204 No Content status.
      Returns:
      the created builder
    • seeOther

      static ServerResponse.BodyBuilder seeOther(URI location)
      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

      static ServerResponse.BodyBuilder temporaryRedirect(URI location)
      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

      static ServerResponse.BodyBuilder permanentRedirect(URI location)
      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

      static ServerResponse.BodyBuilder badRequest()
      Create a builder with a 400 Bad Request status.
      Returns:
      the created builder
    • notFound

      static ServerResponse.HeadersBuilder<?> notFound()
      Create a builder with a 404 Not Found status.
      Returns:
      the created builder
    • unprocessableEntity

      static ServerResponse.BodyBuilder unprocessableEntity()
      Create a builder with an 422 Unprocessable Entity status.
      Returns:
      the created builder