org.springframework.web.reactive.function.server

Interface EntityResponse.Builder<T>

  • Type Parameters:
    T - a self reference to the builder type
    Enclosing interface:
    EntityResponse<T>


    public static interface EntityResponse.Builder<T>
    Defines a builder for EntityResponse.
    • Method Detail

      • header

        EntityResponse.Builder<T> header(java.lang.String headerName,
                                         java.lang.String... headerValues)
        Add the given header value(s) under the given name.
        Parameters:
        headerName - the header name
        headerValues - the header value(s)
        Returns:
        this builder
        See Also:
        HttpHeaders.add(String, String)
      • status

        EntityResponse.Builder<T> status(int status)
        Set the HTTP status.
        Parameters:
        status - the response status
        Returns:
        this builder
        Since:
        5.0.3
      • cookies

        EntityResponse.Builder<T> cookies(java.util.function.Consumer<MultiValueMap<java.lang.String,ResponseCookie>> cookiesConsumer)
        Manipulate this response's cookies with the given consumer. The cookies provided to the consumer are "live", so that the consumer can be used to overwrite existing cookies, remove cookies, or use any of the other MultiValueMap methods.
        Parameters:
        cookiesConsumer - a function that consumes the cookies
        Returns:
        this builder
      • lastModified

        EntityResponse.Builder<T> lastModified(java.time.ZonedDateTime lastModified)
        Set the time the resource was last changed, as specified by the Last-Modified header.

        The date should be specified as the number of milliseconds since January 1, 1970 GMT.

        Parameters:
        lastModified - the last modified date
        Returns:
        this builder
        See Also:
        HttpHeaders.setLastModified(long)
      • cacheControl

        EntityResponse.Builder<T> cacheControl(CacheControl cacheControl)
        Set the caching directives for the resource, as specified by the HTTP 1.1 Cache-Control header.

        A CacheControl instance can be built like CacheControl.maxAge(3600).cachePublic().noTransform().

        Parameters:
        cacheControl - a builder for cache-related HTTP response headers
        Returns:
        this builder
        See Also:
        RFC-7234 Section 5.2
      • varyBy

        EntityResponse.Builder<T> varyBy(java.lang.String... requestHeaders)
        Configure one or more request header names (e.g. "Accept-Language") to add to the "Vary" response header to inform clients that the response is subject to content negotiation and variances based on the value of the given request headers. The configured request header names are added only if not already present in the response "Vary" header.
        Parameters:
        requestHeaders - request header names
        Returns:
        this builder
      • build

        reactor.core.publisher.Mono<EntityResponse<T>> build()
        Build the response.
        Returns:
        the built response