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 ofHttpRequestthat 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 acceptableMediaTypeinstances via theHttpHeaders.ACCEPTheader.default MutableHttpRequest<B>accept(java.lang.CharSequence... mediaTypes)Sets the acceptableMediaTypeinstances via theHttpHeaders.ACCEPTheader.default MutableHttpRequest<B>basicAuth(java.lang.CharSequence username, java.lang.CharSequence password)Set anHttpHeaders.AUTHORIZATIONheader, with value: "Basic Base64(username:password)".default MutableHttpRequest<B>bearerAuth(java.lang.CharSequence token)Set anHttpHeaders.AUTHORIZATIONheader, 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.MutableHttpHeadersgetHeaders()MutableHttpParametersgetParameters()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:MutableHttpMessageSets the body.- Specified by:
bodyin interfaceMutableHttpMessage<B>- Type Parameters:
T- The new body type- Parameters:
body- The body- Returns:
- This message
-
getHeaders
MutableHttpHeaders getHeaders()
- Specified by:
getHeadersin interfaceHttpMessage<B>- Specified by:
getHeadersin interfaceMutableHttpMessage<B>- Returns:
- The
HttpHeadersobject
-
getParameters
MutableHttpParameters getParameters()
- Specified by:
getParametersin 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 acceptableMediaTypeinstances via theHttpHeaders.ACCEPTheader.- Parameters:
mediaTypes- The media types- Returns:
- This request
-
accept
default MutableHttpRequest<B> accept(java.lang.CharSequence... mediaTypes)
Sets the acceptableMediaTypeinstances via theHttpHeaders.ACCEPTheader.- Parameters:
mediaTypes- The media types- Returns:
- This request
-
headers
default MutableHttpRequest<B> headers(java.util.function.Consumer<MutableHttpHeaders> headers)
Description copied from interface:MutableHttpMessageMutate the headers with the given consumer.- Specified by:
headersin 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:MutableHttpMessageSet a response header.- Specified by:
headerin 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:MutableHttpMessageSet anHttpHeaders.AUTHORIZATIONheader, with value: "Basic Base64(username:password)".- Specified by:
basicAuthin 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:MutableHttpMessageSet anHttpHeaders.AUTHORIZATIONheader, with value: "Bearer token".- Specified by:
bearerAuthin 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:MutableHttpMessageSet multiple headers.- Specified by:
headersin interfaceMutableHttpMessage<B>- Parameters:
namesAndValues- The names and values- Returns:
- This response
-
contentLength
default MutableHttpRequest<B> contentLength(long length)
Description copied from interface:MutableHttpMessageSets the content length.- Specified by:
contentLengthin interfaceMutableHttpMessage<B>- Parameters:
length- The length- Returns:
- This response
-
contentType
default MutableHttpRequest<B> contentType(java.lang.CharSequence contentType)
Description copied from interface:MutableHttpMessageSet the response content type.- Specified by:
contentTypein interfaceMutableHttpMessage<B>- Parameters:
contentType- The content type- Returns:
- This response
-
contentType
default MutableHttpRequest<B> contentType(MediaType mediaType)
Description copied from interface:MutableHttpMessageSet the response content type.- Specified by:
contentTypein interfaceMutableHttpMessage<B>- Parameters:
mediaType- The media type- Returns:
- This response
-
contentEncoding
default MutableHttpRequest<B> contentEncoding(java.lang.CharSequence encoding)
Description copied from interface:MutableHttpMessageSets the content encoding.- Specified by:
contentEncodingin interfaceMutableHttpMessage<B>- Parameters:
encoding- The encoding to use- Returns:
- This message
-
-