Package io.micronaut.http
Class HttpRequestWrapper<B>
- java.lang.Object
-
- io.micronaut.http.HttpMessageWrapper<B>
-
- io.micronaut.http.HttpRequestWrapper<B>
-
- Type Parameters:
B
- The Http body type
- All Implemented Interfaces:
io.micronaut.core.attr.AttributeHolder
,io.micronaut.core.attr.MutableAttributeHolder
,HttpMessage<B>
,HttpRequest<B>
- Direct Known Subclasses:
FullHttpRequest
public class HttpRequestWrapper<B> extends HttpMessageWrapper<B> implements HttpRequest<B>
A wrapper around aHttpRequest
.- Since:
- 1.0
-
-
Field Summary
-
Fields inherited from interface io.micronaut.http.HttpRequest
SCHEME_HTTP, SCHEME_HTTPS
-
-
Constructor Summary
Constructors Constructor Description HttpRequestWrapper(HttpRequest<B> delegate)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Collection<MediaType>
accept()
A list of acceptedMediaType
instances sorted by their quality rating.java.util.Optional<java.security.cert.Certificate>
getCertificate()
Retrieves the Certificate used for mutual authentication.Cookies
getCookies()
HttpRequest<B>
getDelegate()
HttpVersion
getHttpVersion()
java.util.Optional<java.util.Locale>
getLocale()
HttpMethod
getMethod()
java.lang.String
getMethodName()
HttpParameters
getParameters()
java.lang.String
getPath()
java.net.InetSocketAddress
getRemoteAddress()
java.net.InetSocketAddress
getServerAddress()
java.lang.String
getServerName()
java.net.URI
getUri()
java.util.Optional<java.security.Principal>
getUserPrincipal()
The user principal stored within the request.<T extends java.security.Principal>
java.util.Optional<T>getUserPrincipal(java.lang.Class<T> principalType)
The user principal stored within the request.boolean
isSecure()
HttpRequest<B>
setAttribute(java.lang.CharSequence name, java.lang.Object value)
-
Methods inherited from class io.micronaut.http.HttpMessageWrapper
getAttributes, getBody, getBody, getBody, getHeaders
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.micronaut.http.HttpMessage
getAttributes, getBody, getBody, getBody, getCharacterEncoding, getContentLength, getContentType, getHeaders
-
Methods inherited from interface io.micronaut.http.HttpRequest
mutate
-
-
-
-
Constructor Detail
-
HttpRequestWrapper
public HttpRequestWrapper(HttpRequest<B> delegate)
- Parameters:
delegate
- The Http Request
-
-
Method Detail
-
getDelegate
public HttpRequest<B> getDelegate()
- Overrides:
getDelegate
in classHttpMessageWrapper<B>
- Returns:
- The Http message
-
getHttpVersion
public HttpVersion getHttpVersion()
- Specified by:
getHttpVersion
in interfaceHttpRequest<B>
- Returns:
- The http version of the request.
-
accept
public java.util.Collection<MediaType> accept()
Description copied from interface:HttpRequest
A list of acceptedMediaType
instances sorted by their quality rating.- Specified by:
accept
in interfaceHttpRequest<B>
- Returns:
- A list of zero or many
MediaType
instances
-
getUserPrincipal
@NonNull public java.util.Optional<java.security.Principal> getUserPrincipal()
Description copied from interface:HttpRequest
The user principal stored within the request.- Specified by:
getUserPrincipal
in interfaceHttpRequest<B>
- Returns:
- The principal
-
getUserPrincipal
@NonNull public <T extends java.security.Principal> java.util.Optional<T> getUserPrincipal(java.lang.Class<T> principalType)
Description copied from interface:HttpRequest
The user principal stored within the request.- Specified by:
getUserPrincipal
in interfaceHttpRequest<B>
- Type Parameters:
T
- The principal type- Parameters:
principalType
- The principal type- Returns:
- The principal
-
setAttribute
public HttpRequest<B> setAttribute(java.lang.CharSequence name, java.lang.Object value)
- Specified by:
setAttribute
in interfaceHttpMessage<B>
- Specified by:
setAttribute
in interfaceHttpRequest<B>
- Specified by:
setAttribute
in interfaceio.micronaut.core.attr.MutableAttributeHolder
-
getLocale
public java.util.Optional<java.util.Locale> getLocale()
- Specified by:
getLocale
in interfaceHttpMessage<B>
- Specified by:
getLocale
in interfaceHttpRequest<B>
- Returns:
- The locale of the message
-
getCertificate
public java.util.Optional<java.security.cert.Certificate> getCertificate()
Description copied from interface:HttpRequest
Retrieves the Certificate used for mutual authentication.- Specified by:
getCertificate
in interfaceHttpRequest<B>
- Returns:
- A certificate used for authentication, if applicable.
-
getCookies
public Cookies getCookies()
- Specified by:
getCookies
in interfaceHttpRequest<B>
- Returns:
- The
Cookies
instance
-
getParameters
public HttpParameters getParameters()
- Specified by:
getParameters
in interfaceHttpRequest<B>
- Returns:
- The HTTP parameters contained with the URI query string
-
getMethod
public HttpMethod getMethod()
- Specified by:
getMethod
in interfaceHttpRequest<B>
- Returns:
- The request method
-
getMethodName
public java.lang.String getMethodName()
- Specified by:
getMethodName
in interfaceHttpRequest<B>
- Returns:
- The name of the method (same as
HttpMethod
value for standard http methods).
-
getUri
public java.net.URI getUri()
- Specified by:
getUri
in interfaceHttpRequest<B>
- Returns:
- The full request URI
-
getPath
public java.lang.String getPath()
- Specified by:
getPath
in interfaceHttpRequest<B>
- Returns:
- Get the raw, percent-encoded path without any parameters
-
getRemoteAddress
public java.net.InetSocketAddress getRemoteAddress()
- Specified by:
getRemoteAddress
in interfaceHttpRequest<B>
- Returns:
- Obtain the remote address
-
getServerAddress
public java.net.InetSocketAddress getServerAddress()
- Specified by:
getServerAddress
in interfaceHttpRequest<B>
- Returns:
- Obtain the server address
-
getServerName
public java.lang.String getServerName()
- Specified by:
getServerName
in interfaceHttpRequest<B>
- Returns:
- The server host name
-
isSecure
public boolean isSecure()
- Specified by:
isSecure
in interfaceHttpRequest<B>
- Returns:
- Is the request an HTTPS request
-
-