Package io.micronaut.http
Interface MutableHttpRequest<B>
-
- Type Parameters:
B
- The request body type
- All Superinterfaces:
io.micronaut.core.attr.AttributeHolder
,HttpMessage<B>
,HttpRequest<B>
,io.micronaut.core.attr.MutableAttributeHolder
,MutableHttpMessage<B>
- All Known Implementing Classes:
SimpleHttpRequest
public interface MutableHttpRequest<B> extends HttpRequest<B>, MutableHttpMessage<B>
An extended version ofHttpRequest
that allows mutating headers, the body etc.- Since:
- 1.0
-
-
Field Summary
-
Fields inherited from interface io.micronaut.http.HttpRequest
SCHEME_HTTP, SCHEME_HTTPS
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default MutableHttpRequest<B>
accept(MediaType... mediaTypes)
Sets the acceptableMediaType
instances via theHttpHeaders.ACCEPT
header.default MutableHttpRequest<B>
accept(java.lang.CharSequence... mediaTypes)
Sets the acceptableMediaType
instances via theHttpHeaders.ACCEPT
header.default MutableHttpRequest<B>
basicAuth(java.lang.CharSequence username, java.lang.CharSequence password)
Set anHttpHeaders.AUTHORIZATION
header, with value: "Basic Base64(username:password)".default MutableHttpRequest<B>
bearerAuth(java.lang.CharSequence token)
Set anHttpHeaders.AUTHORIZATION
header, with value: "Bearer token".<T> MutableHttpRequest<T>
body(T body)
Sets the body.default MutableHttpRequest<B>
contentEncoding(java.lang.CharSequence encoding)
Sets the content encoding.default MutableHttpRequest<B>
contentLength(long length)
Sets the content length.default MutableHttpRequest<B>
contentType(MediaType mediaType)
Set the response content type.default MutableHttpRequest<B>
contentType(java.lang.CharSequence contentType)
Set the response content type.MutableHttpRequest<B>
cookie(Cookie cookie)
Sets the specified cookie on the request.default MutableHttpRequest<B>
cookies(java.util.Set<Cookie> cookies)
Sets the specified cookies on the request.MutableHttpHeaders
getHeaders()
MutableHttpParameters
getParameters()
default MutableHttpRequest<B>
header(java.lang.CharSequence name, java.lang.CharSequence value)
Set a response header.default MutableHttpRequest<B>
headers(java.util.function.Consumer<MutableHttpHeaders> headers)
Mutate the headers with the given consumer.default MutableHttpRequest<B>
headers(java.util.Map<java.lang.CharSequence,java.lang.CharSequence> namesAndValues)
Set multiple headers.MutableHttpRequest<B>
uri(java.net.URI uri)
Sets the uri on the request.default MutableHttpRequest<B>
uri(java.util.function.Consumer<UriBuilder> consumer)
Alters the URI of the request with the given URI builder.-
Methods inherited from interface io.micronaut.http.HttpMessage
getAttributes, getBody, getBody, getBody, getCharacterEncoding, getContentLength, getContentType
-
Methods inherited from interface io.micronaut.http.HttpRequest
accept, getCertificate, getCookies, getHttpVersion, getLocale, getMethod, getMethodName, getPath, getRemoteAddress, getServerAddress, getServerName, getUri, getUserPrincipal, getUserPrincipal, isSecure, mutate, setAttribute
-
-
-
-
Method Detail
-
cookie
MutableHttpRequest<B> cookie(Cookie cookie)
Sets the specified cookie on the request.- Parameters:
cookie
- the Cookie to return to the client- Returns:
- The http request
-
cookies
default MutableHttpRequest<B> cookies(java.util.Set<Cookie> cookies)
Sets the specified cookies on the request.- Parameters:
cookies
- the Cookies to return to the client- Returns:
- The http request
-
uri
MutableHttpRequest<B> uri(java.net.URI uri)
Sets the uri on the request.- Parameters:
uri
- The uri to call- Returns:
- The http request
-
body
<T> MutableHttpRequest<T> body(T body)
Description copied from interface:MutableHttpMessage
Sets the body.- Specified by:
body
in interfaceMutableHttpMessage<B>
- Type Parameters:
T
- The new body type- Parameters:
body
- The body- Returns:
- This message
-
getHeaders
MutableHttpHeaders getHeaders()
- Specified by:
getHeaders
in interfaceHttpMessage<B>
- Specified by:
getHeaders
in interfaceMutableHttpMessage<B>
- Returns:
- The
HttpHeaders
object
-
getParameters
MutableHttpParameters getParameters()
- Specified by:
getParameters
in interfaceHttpRequest<B>
- Returns:
- The HTTP parameters contained with the URI query string
-
uri
@NonNull default MutableHttpRequest<B> uri(@NonNull java.util.function.Consumer<UriBuilder> consumer)
Alters the URI of the request with the given URI builder.- Parameters:
consumer
- A consumer that accepts the URI- Returns:
- The modified request
-
accept
default MutableHttpRequest<B> accept(MediaType... mediaTypes)
Sets the acceptableMediaType
instances via theHttpHeaders.ACCEPT
header.- Parameters:
mediaTypes
- The media types- Returns:
- This request
-
accept
default MutableHttpRequest<B> accept(java.lang.CharSequence... mediaTypes)
Sets the acceptableMediaType
instances via theHttpHeaders.ACCEPT
header.- Parameters:
mediaTypes
- The media types- Returns:
- This request
-
headers
default MutableHttpRequest<B> headers(java.util.function.Consumer<MutableHttpHeaders> headers)
Description copied from interface:MutableHttpMessage
Mutate the headers with the given consumer.- Specified by:
headers
in interfaceMutableHttpMessage<B>
- Parameters:
headers
- The headers- Returns:
- This response
-
header
default MutableHttpRequest<B> header(java.lang.CharSequence name, java.lang.CharSequence value)
Description copied from interface:MutableHttpMessage
Set a response header.- Specified by:
header
in interfaceMutableHttpMessage<B>
- Parameters:
name
- The name of the headervalue
- The value of the header- Returns:
- This response
-
basicAuth
default MutableHttpRequest<B> basicAuth(java.lang.CharSequence username, java.lang.CharSequence password)
Description copied from interface:MutableHttpMessage
Set anHttpHeaders.AUTHORIZATION
header, with value: "Basic Base64(username:password)".- Specified by:
basicAuth
in interfaceMutableHttpMessage<B>
- Parameters:
username
- The username part of the credentialspassword
- The password part of the credentials- Returns:
- This response
-
bearerAuth
default MutableHttpRequest<B> bearerAuth(java.lang.CharSequence token)
Description copied from interface:MutableHttpMessage
Set anHttpHeaders.AUTHORIZATION
header, with value: "Bearer token".- Specified by:
bearerAuth
in interfaceMutableHttpMessage<B>
- Parameters:
token
- The token- Returns:
- This response
-
headers
default MutableHttpRequest<B> headers(java.util.Map<java.lang.CharSequence,java.lang.CharSequence> namesAndValues)
Description copied from interface:MutableHttpMessage
Set multiple headers.- Specified by:
headers
in interfaceMutableHttpMessage<B>
- Parameters:
namesAndValues
- The names and values- Returns:
- This response
-
contentLength
default MutableHttpRequest<B> contentLength(long length)
Description copied from interface:MutableHttpMessage
Sets the content length.- Specified by:
contentLength
in interfaceMutableHttpMessage<B>
- Parameters:
length
- The length- Returns:
- This response
-
contentType
default MutableHttpRequest<B> contentType(java.lang.CharSequence contentType)
Description copied from interface:MutableHttpMessage
Set the response content type.- Specified by:
contentType
in interfaceMutableHttpMessage<B>
- Parameters:
contentType
- The content type- Returns:
- This response
-
contentType
default MutableHttpRequest<B> contentType(MediaType mediaType)
Description copied from interface:MutableHttpMessage
Set the response content type.- Specified by:
contentType
in interfaceMutableHttpMessage<B>
- Parameters:
mediaType
- The media type- Returns:
- This response
-
contentEncoding
default MutableHttpRequest<B> contentEncoding(java.lang.CharSequence encoding)
Description copied from interface:MutableHttpMessage
Sets the content encoding.- Specified by:
contentEncoding
in interfaceMutableHttpMessage<B>
- Parameters:
encoding
- The encoding to use- Returns:
- This message
-
-