Interface EntityResponse.Builder<T>
- Type Parameters:
T
- the entity type
- Enclosing interface:
- EntityResponse<T>
public static interface EntityResponse.Builder<T>
Defines a builder for
EntityResponse
.-
Method Summary
Modifier and TypeMethodDescriptionallow
(Set<HttpMethod> allowedMethods) Set the set of allowedHTTP methods
, as specified by theAllow
header.allow
(HttpMethod... allowedMethods) Set the set of allowedHTTP methods
, as specified by theAllow
header.build()
Build the response.cacheControl
(CacheControl cacheControl) Set the caching directives for the resource, as specified by the HTTP 1.1Cache-Control
header.contentLength
(long contentLength) Set the length of the body in bytes, as specified by theContent-Length
header.contentType
(MediaType contentType) Set the media type of the body, as specified by theContent-Type
header.Add the given cookie to the response.cookies
(Consumer<MultiValueMap<String, Cookie>> cookiesConsumer) Manipulate this response's cookies with the given consumer.Set the entity tag of the body, as specified by theETag
header.Add the given header value(s) under the given name.headers
(Consumer<HttpHeaders> headersConsumer) Manipulate this response's headers with the given consumer.lastModified
(Instant lastModified) Set the time the resource was last changed, as specified by theLast-Modified
header.lastModified
(ZonedDateTime lastModified) Set the time the resource was last changed, as specified by theLast-Modified
header.Set the location of a resource, as specified by theLocation
header.status
(int status) Set the HTTP status.status
(HttpStatus status) Set the HTTP status.Configure one or more request header names (e.g.
-
Method Details
-
header
Add the given header value(s) under the given name.- Parameters:
headerName
- the header nameheaderValues
- the header value(s)- Returns:
- this builder
- See Also:
-
headers
Manipulate this response'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 otherHttpHeaders
methods.- Parameters:
headersConsumer
- a function that consumes theHttpHeaders
- Returns:
- this builder
-
status
Set the HTTP status.- Parameters:
status
- the response status- Returns:
- this builder
-
status
Set the HTTP status.- Parameters:
status
- the response status- Returns:
- this builder
-
cookie
Add the given cookie to the response.- Parameters:
cookie
- the cookie to add- Returns:
- this builder
-
cookies
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 otherMultiValueMap
methods.- Parameters:
cookiesConsumer
- a function that consumes the cookies- Returns:
- this builder
-
allow
Set the set of allowedHTTP methods
, as specified by theAllow
header.- Parameters:
allowedMethods
- the allowed methods- Returns:
- this builder
- See Also:
-
allow
Set the set of allowedHTTP methods
, as specified by theAllow
header.- Parameters:
allowedMethods
- the allowed methods- Returns:
- this builder
- See Also:
-
eTag
Set the entity tag of the body, as specified by theETag
header.- Parameters:
etag
- the new entity tag- Returns:
- this builder
- See Also:
-
lastModified
Set the time the resource was last changed, as specified by theLast-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:
-
lastModified
Set the time the resource was last changed, as specified by theLast-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
- Since:
- 5.1.4
- See Also:
-
location
Set the location of a resource, as specified by theLocation
header.- Parameters:
location
- the location- Returns:
- this builder
- See Also:
-
cacheControl
Set the caching directives for the resource, as specified by the HTTP 1.1Cache-Control
header.A
CacheControl
instance can be built likeCacheControl.maxAge(3600).cachePublic().noTransform()
.- Parameters:
cacheControl
- a builder for cache-related HTTP response headers- Returns:
- this builder
- See Also:
-
varyBy
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
-
contentLength
Set the length of the body in bytes, as specified by theContent-Length
header.- Parameters:
contentLength
- the content length- Returns:
- this builder
- See Also:
-
contentType
Set the media type of the body, as specified by theContent-Type
header.- Parameters:
contentType
- the content type- Returns:
- this builder
- See Also:
-
build
EntityResponse<T> build()Build the response.- Returns:
- the built response
-