Package io.micronaut.http
Interface HttpRequest<B>
-
- Type Parameters:
B
- The Http message body
- All Superinterfaces:
io.micronaut.core.attr.AttributeHolder
,HttpMessage<B>
,io.micronaut.core.attr.MutableAttributeHolder
- All Known Subinterfaces:
MutableHttpRequest<B>
,PushCapableHttpRequest<B>
- All Known Implementing Classes:
FullHttpRequest
,HttpRequestWrapper
,SimpleHttpRequest
public interface HttpRequest<B> extends HttpMessage<B>
Common interface for HTTP request implementations.
- Since:
- 1.0
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
SCHEME_HTTP
Constant for HTTP scheme.static java.lang.String
SCHEME_HTTPS
Constant for HTTPS scheme.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default java.util.Collection<MediaType>
accept()
A list of acceptedMediaType
instances sorted by their quality rating.static <T> MutableHttpRequest<T>
create(HttpMethod httpMethod, java.lang.String uri)
Create a newMutableHttpRequest
for the given method and URI.static <T> MutableHttpRequest<T>
create(HttpMethod httpMethod, java.lang.String uri, java.lang.String httpMethodName)
Create a newMutableHttpRequest
for the given method and URI.static <T> MutableHttpRequest<T>
DELETE(java.lang.String uri)
Return aMutableHttpRequest
that executes anHttpMethod.DELETE
request for the given URI.static <T> MutableHttpRequest<T>
DELETE(java.lang.String uri, T body)
Return aMutableHttpRequest
that executes anHttpMethod.DELETE
request for the given URI.static <T> MutableHttpRequest<T>
DELETE(java.net.URI uri)
Return aMutableHttpRequest
that executes anHttpMethod.DELETE
request for the given URI.static <T> MutableHttpRequest<T>
DELETE(java.net.URI uri, T body)
Return aMutableHttpRequest
that executes anHttpMethod.DELETE
request for the given URI.static <T> MutableHttpRequest<T>
GET(java.lang.String uri)
Return aMutableHttpRequest
for aHttpMethod.GET
request for the given URI.static <T> MutableHttpRequest<T>
GET(java.net.URI uri)
Return aMutableHttpRequest
for aHttpMethod.GET
request for the given URI.default java.util.Optional<java.security.cert.Certificate>
getCertificate()
Retrieves the Certificate used for mutual authentication.Cookies
getCookies()
default HttpVersion
getHttpVersion()
default java.util.Optional<java.util.Locale>
getLocale()
HttpMethod
getMethod()
default java.lang.String
getMethodName()
HttpParameters
getParameters()
default java.lang.String
getPath()
default java.net.InetSocketAddress
getRemoteAddress()
default java.net.InetSocketAddress
getServerAddress()
default java.lang.String
getServerName()
java.net.URI
getUri()
default java.util.Optional<java.security.Principal>
getUserPrincipal()
The user principal stored within the request.default <T extends java.security.Principal>
java.util.Optional<T>getUserPrincipal(java.lang.Class<T> principalType)
The user principal stored within the request.static MutableHttpRequest<?>
HEAD(java.lang.String uri)
Return aMutableHttpRequest
for aHttpMethod.HEAD
request for the given URI.static MutableHttpRequest<?>
HEAD(java.net.URI uri)
Return aMutableHttpRequest
for aHttpMethod.HEAD
request for the given URI.default boolean
isSecure()
default MutableHttpRequest<B>
mutate()
Returns a new request object that allows mutation.static <T> MutableHttpRequest<T>
OPTIONS(java.lang.String uri)
Return aMutableHttpRequest
for aHttpMethod.OPTIONS
request for the given URI.static <T> MutableHttpRequest<T>
OPTIONS(java.net.URI uri)
Return aMutableHttpRequest
for aHttpMethod.OPTIONS
request for the given URI.static <T> MutableHttpRequest<T>
PATCH(java.lang.String uri, T body)
Return aMutableHttpRequest
that executes anHttpMethod.PATCH
request for the given URI.static <T> MutableHttpRequest<T>
PATCH(java.net.URI uri, T body)
Return aMutableHttpRequest
that executes anHttpMethod.PATCH
request for the given URI.static <T> MutableHttpRequest<T>
POST(java.lang.String uri, T body)
Return aMutableHttpRequest
that executes anHttpMethod.POST
request for the given URI.static <T> MutableHttpRequest<T>
POST(java.net.URI uri, T body)
Return aMutableHttpRequest
that executes anHttpMethod.POST
request for the given URI.static <T> MutableHttpRequest<T>
PUT(java.lang.String uri, T body)
Return aMutableHttpRequest
that executes anHttpMethod.PUT
request for the given URI.static <T> MutableHttpRequest<T>
PUT(java.net.URI uri, T body)
Return aMutableHttpRequest
that executes anHttpMethod.PUT
request for the given URI.default HttpRequest<B>
setAttribute(java.lang.CharSequence name, java.lang.Object value)
-
Methods inherited from interface io.micronaut.http.HttpMessage
getAttributes, getBody, getBody, getBody, getCharacterEncoding, getContentLength, getContentType, getHeaders
-
-
-
-
Field Detail
-
SCHEME_HTTP
static final java.lang.String SCHEME_HTTP
Constant for HTTP scheme.- See Also:
- Constant Field Values
-
SCHEME_HTTPS
static final java.lang.String SCHEME_HTTPS
Constant for HTTPS scheme.- See Also:
- Constant Field Values
-
-
Method Detail
-
getParameters
@NonNull HttpParameters getParameters()
- Returns:
- The HTTP parameters contained with the URI query string
-
getMethod
@NonNull HttpMethod getMethod()
- Returns:
- The request method
-
getUri
@NonNull java.net.URI getUri()
- Returns:
- The full request URI
-
mutate
default MutableHttpRequest<B> mutate()
Returns a new request object that allows mutation.- Returns:
- The mutable request
- Since:
- 2.0.0
-
getHttpVersion
default HttpVersion getHttpVersion()
- Returns:
- The http version of the request.
-
accept
default java.util.Collection<MediaType> accept()
A list of acceptedMediaType
instances sorted by their quality rating.- Returns:
- A list of zero or many
MediaType
instances
-
getMethodName
@NonNull default java.lang.String getMethodName()
- Returns:
- The name of the method (same as
HttpMethod
value for standard http methods).
-
getUserPrincipal
@NonNull default java.util.Optional<java.security.Principal> getUserPrincipal()
The user principal stored within the request.- Returns:
- The principal
- Since:
- 1.0.4
-
getUserPrincipal
@NonNull default <T extends java.security.Principal> java.util.Optional<T> getUserPrincipal(java.lang.Class<T> principalType)
The user principal stored within the request.- Type Parameters:
T
- The principal type- Parameters:
principalType
- The principal type- Returns:
- The principal
- Since:
- 1.0.4
-
getPath
@NonNull default java.lang.String getPath()
- Returns:
- Get the raw, percent-encoded path without any parameters
-
getRemoteAddress
@NonNull default java.net.InetSocketAddress getRemoteAddress()
- Returns:
- Obtain the remote address
-
getServerAddress
@NonNull default java.net.InetSocketAddress getServerAddress()
- Returns:
- Obtain the server address
-
getServerName
@Nullable default java.lang.String getServerName()
- Returns:
- The server host name
-
isSecure
default boolean isSecure()
- Returns:
- Is the request an HTTPS request
-
setAttribute
default HttpRequest<B> setAttribute(java.lang.CharSequence name, java.lang.Object value)
- Specified by:
setAttribute
in interfaceHttpMessage<B>
- Specified by:
setAttribute
in interfaceio.micronaut.core.attr.MutableAttributeHolder
-
getLocale
default java.util.Optional<java.util.Locale> getLocale()
- Specified by:
getLocale
in interfaceHttpMessage<B>
- Returns:
- The locale of the message
-
getCertificate
default java.util.Optional<java.security.cert.Certificate> getCertificate()
Retrieves the Certificate used for mutual authentication.- Returns:
- A certificate used for authentication, if applicable.
-
GET
static <T> MutableHttpRequest<T> GET(java.net.URI uri)
Return aMutableHttpRequest
for aHttpMethod.GET
request for the given URI.- Type Parameters:
T
- The Http request type- Parameters:
uri
- The URI- Returns:
- The
MutableHttpRequest
instance - See Also:
HttpRequestFactory
-
GET
static <T> MutableHttpRequest<T> GET(java.lang.String uri)
Return aMutableHttpRequest
for aHttpMethod.GET
request for the given URI.- Type Parameters:
T
- The Http request type- Parameters:
uri
- The URI- Returns:
- The
MutableHttpRequest
instance - See Also:
HttpRequestFactory
-
OPTIONS
static <T> MutableHttpRequest<T> OPTIONS(java.net.URI uri)
Return aMutableHttpRequest
for aHttpMethod.OPTIONS
request for the given URI.- Type Parameters:
T
- The Http request type- Parameters:
uri
- The URI- Returns:
- The
MutableHttpRequest
instance - See Also:
HttpRequestFactory
-
OPTIONS
static <T> MutableHttpRequest<T> OPTIONS(java.lang.String uri)
Return aMutableHttpRequest
for aHttpMethod.OPTIONS
request for the given URI.- Type Parameters:
T
- The Http request type- Parameters:
uri
- The URI- Returns:
- The
MutableHttpRequest
instance - See Also:
HttpRequestFactory
-
HEAD
static MutableHttpRequest<?> HEAD(java.net.URI uri)
Return aMutableHttpRequest
for aHttpMethod.HEAD
request for the given URI.- Parameters:
uri
- The URI- Returns:
- The
MutableHttpRequest
instance - See Also:
HttpRequestFactory
-
HEAD
static MutableHttpRequest<?> HEAD(java.lang.String uri)
Return aMutableHttpRequest
for aHttpMethod.HEAD
request for the given URI.- Parameters:
uri
- The URI- Returns:
- The
MutableHttpRequest
instance - See Also:
HttpRequestFactory
-
POST
static <T> MutableHttpRequest<T> POST(java.net.URI uri, T body)
Return aMutableHttpRequest
that executes anHttpMethod.POST
request for the given URI.- Type Parameters:
T
- The body type- Parameters:
uri
- The URIbody
- The body of the request (content type defaults toMediaType.APPLICATION_JSON
- Returns:
- The
MutableHttpRequest
instance - See Also:
HttpRequestFactory
-
POST
static <T> MutableHttpRequest<T> POST(java.lang.String uri, T body)
Return aMutableHttpRequest
that executes anHttpMethod.POST
request for the given URI.- Type Parameters:
T
- The body type- Parameters:
uri
- The URIbody
- The body of the request (content type defaults toMediaType.APPLICATION_JSON
- Returns:
- The
MutableHttpRequest
instance - See Also:
HttpRequestFactory
-
PUT
static <T> MutableHttpRequest<T> PUT(java.net.URI uri, T body)
Return aMutableHttpRequest
that executes anHttpMethod.PUT
request for the given URI.- Type Parameters:
T
- The body type- Parameters:
uri
- The URIbody
- The body of the request (content type defaults toMediaType.APPLICATION_JSON
- Returns:
- The
MutableHttpRequest
instance - See Also:
HttpRequestFactory
-
PUT
static <T> MutableHttpRequest<T> PUT(java.lang.String uri, T body)
Return aMutableHttpRequest
that executes anHttpMethod.PUT
request for the given URI.- Type Parameters:
T
- The body type- Parameters:
uri
- The URIbody
- The body of the request (content type defaults toMediaType.APPLICATION_JSON
- Returns:
- The
MutableHttpRequest
instance - See Also:
HttpRequestFactory
-
PATCH
static <T> MutableHttpRequest<T> PATCH(java.net.URI uri, T body)
Return aMutableHttpRequest
that executes anHttpMethod.PATCH
request for the given URI.- Type Parameters:
T
- The body type- Parameters:
uri
- The URIbody
- The body of the request (content type defaults toMediaType.APPLICATION_JSON
- Returns:
- The
MutableHttpRequest
instance - See Also:
HttpRequestFactory
-
PATCH
static <T> MutableHttpRequest<T> PATCH(java.lang.String uri, T body)
Return aMutableHttpRequest
that executes anHttpMethod.PATCH
request for the given URI.- Type Parameters:
T
- The body type- Parameters:
uri
- The URIbody
- The body of the request (content type defaults toMediaType.APPLICATION_JSON
- Returns:
- The
MutableHttpRequest
instance - See Also:
HttpRequestFactory
-
DELETE
static <T> MutableHttpRequest<T> DELETE(java.net.URI uri, T body)
Return aMutableHttpRequest
that executes anHttpMethod.DELETE
request for the given URI.- Type Parameters:
T
- The body type- Parameters:
uri
- The URIbody
- The body of the request (content type defaults toMediaType.APPLICATION_JSON
- Returns:
- The
MutableHttpRequest
instance - See Also:
HttpRequestFactory
-
DELETE
static <T> MutableHttpRequest<T> DELETE(java.lang.String uri, T body)
Return aMutableHttpRequest
that executes anHttpMethod.DELETE
request for the given URI.- Type Parameters:
T
- The body type- Parameters:
uri
- The URIbody
- The body of the request (content type defaults toMediaType.APPLICATION_JSON
- Returns:
- The
MutableHttpRequest
instance - See Also:
HttpRequestFactory
-
DELETE
static <T> MutableHttpRequest<T> DELETE(java.lang.String uri)
Return aMutableHttpRequest
that executes anHttpMethod.DELETE
request for the given URI.- Type Parameters:
T
- The Http request type- Parameters:
uri
- The URI- Returns:
- The
MutableHttpRequest
instance - See Also:
HttpRequestFactory
-
DELETE
static <T> MutableHttpRequest<T> DELETE(java.net.URI uri)
Return aMutableHttpRequest
that executes anHttpMethod.DELETE
request for the given URI.- Type Parameters:
T
- The Http request type- Parameters:
uri
- The URI- Returns:
- The
MutableHttpRequest
instance - See Also:
HttpRequestFactory
-
create
static <T> MutableHttpRequest<T> create(HttpMethod httpMethod, java.lang.String uri)
Create a newMutableHttpRequest
for the given method and URI.- Type Parameters:
T
- The Http request type- Parameters:
httpMethod
- The methoduri
- The URI- Returns:
- The request
-
create
static <T> MutableHttpRequest<T> create(HttpMethod httpMethod, java.lang.String uri, java.lang.String httpMethodName)
Create a newMutableHttpRequest
for the given method and URI.- Type Parameters:
T
- The Http request type- Parameters:
httpMethod
- The methoduri
- The URIhttpMethodName
- Method name - for standard http methods is equal toEnum.name()
- Returns:
- The request
-
-