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.StringSCHEME_HTTPConstant for HTTP scheme.static java.lang.StringSCHEME_HTTPSConstant 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 acceptedMediaTypeinstances sorted by their quality rating.static <T> MutableHttpRequest<T>create(HttpMethod httpMethod, java.lang.String uri)Create a newMutableHttpRequestfor the given method and URI.static <T> MutableHttpRequest<T>create(HttpMethod httpMethod, java.lang.String uri, java.lang.String httpMethodName)Create a newMutableHttpRequestfor the given method and URI.static <T> MutableHttpRequest<T>DELETE(java.lang.String uri)Return aMutableHttpRequestthat executes anHttpMethod.DELETErequest for the given URI.static <T> MutableHttpRequest<T>DELETE(java.lang.String uri, T body)Return aMutableHttpRequestthat executes anHttpMethod.DELETErequest for the given URI.static <T> MutableHttpRequest<T>DELETE(java.net.URI uri)Return aMutableHttpRequestthat executes anHttpMethod.DELETErequest for the given URI.static <T> MutableHttpRequest<T>DELETE(java.net.URI uri, T body)Return aMutableHttpRequestthat executes anHttpMethod.DELETErequest for the given URI.static <T> MutableHttpRequest<T>GET(java.lang.String uri)Return aMutableHttpRequestfor aHttpMethod.GETrequest for the given URI.static <T> MutableHttpRequest<T>GET(java.net.URI uri)Return aMutableHttpRequestfor aHttpMethod.GETrequest for the given URI.default java.util.Optional<java.security.cert.Certificate>getCertificate()Retrieves the Certificate used for mutual authentication.CookiesgetCookies()default HttpVersiongetHttpVersion()default java.util.Optional<java.util.Locale>getLocale()HttpMethodgetMethod()default java.lang.StringgetMethodName()HttpParametersgetParameters()default java.lang.StringgetPath()default java.net.InetSocketAddressgetRemoteAddress()default java.net.InetSocketAddressgetServerAddress()default java.lang.StringgetServerName()java.net.URIgetUri()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 aMutableHttpRequestfor aHttpMethod.HEADrequest for the given URI.static MutableHttpRequest<?>HEAD(java.net.URI uri)Return aMutableHttpRequestfor aHttpMethod.HEADrequest for the given URI.default booleanisSecure()default MutableHttpRequest<B>mutate()Returns a new request object that allows mutation.static <T> MutableHttpRequest<T>OPTIONS(java.lang.String uri)Return aMutableHttpRequestfor aHttpMethod.OPTIONSrequest for the given URI.static <T> MutableHttpRequest<T>OPTIONS(java.net.URI uri)Return aMutableHttpRequestfor aHttpMethod.OPTIONSrequest for the given URI.static <T> MutableHttpRequest<T>PATCH(java.lang.String uri, T body)Return aMutableHttpRequestthat executes anHttpMethod.PATCHrequest for the given URI.static <T> MutableHttpRequest<T>PATCH(java.net.URI uri, T body)Return aMutableHttpRequestthat executes anHttpMethod.PATCHrequest for the given URI.static <T> MutableHttpRequest<T>POST(java.lang.String uri, T body)Return aMutableHttpRequestthat executes anHttpMethod.POSTrequest for the given URI.static <T> MutableHttpRequest<T>POST(java.net.URI uri, T body)Return aMutableHttpRequestthat executes anHttpMethod.POSTrequest for the given URI.static <T> MutableHttpRequest<T>PUT(java.lang.String uri, T body)Return aMutableHttpRequestthat executes anHttpMethod.PUTrequest for the given URI.static <T> MutableHttpRequest<T>PUT(java.net.URI uri, T body)Return aMutableHttpRequestthat executes anHttpMethod.PUTrequest 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 acceptedMediaTypeinstances sorted by their quality rating.- Returns:
- A list of zero or many
MediaTypeinstances
-
getMethodName
@NonNull default java.lang.String getMethodName()
- Returns:
- The name of the method (same as
HttpMethodvalue 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:
setAttributein interfaceHttpMessage<B>- Specified by:
setAttributein interfaceio.micronaut.core.attr.MutableAttributeHolder
-
getLocale
default java.util.Optional<java.util.Locale> getLocale()
- Specified by:
getLocalein 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 aMutableHttpRequestfor aHttpMethod.GETrequest for the given URI.- Type Parameters:
T- The Http request type- Parameters:
uri- The URI- Returns:
- The
MutableHttpRequestinstance - See Also:
HttpRequestFactory
-
GET
static <T> MutableHttpRequest<T> GET(java.lang.String uri)
Return aMutableHttpRequestfor aHttpMethod.GETrequest for the given URI.- Type Parameters:
T- The Http request type- Parameters:
uri- The URI- Returns:
- The
MutableHttpRequestinstance - See Also:
HttpRequestFactory
-
OPTIONS
static <T> MutableHttpRequest<T> OPTIONS(java.net.URI uri)
Return aMutableHttpRequestfor aHttpMethod.OPTIONSrequest for the given URI.- Type Parameters:
T- The Http request type- Parameters:
uri- The URI- Returns:
- The
MutableHttpRequestinstance - See Also:
HttpRequestFactory
-
OPTIONS
static <T> MutableHttpRequest<T> OPTIONS(java.lang.String uri)
Return aMutableHttpRequestfor aHttpMethod.OPTIONSrequest for the given URI.- Type Parameters:
T- The Http request type- Parameters:
uri- The URI- Returns:
- The
MutableHttpRequestinstance - See Also:
HttpRequestFactory
-
HEAD
static MutableHttpRequest<?> HEAD(java.net.URI uri)
Return aMutableHttpRequestfor aHttpMethod.HEADrequest for the given URI.- Parameters:
uri- The URI- Returns:
- The
MutableHttpRequestinstance - See Also:
HttpRequestFactory
-
HEAD
static MutableHttpRequest<?> HEAD(java.lang.String uri)
Return aMutableHttpRequestfor aHttpMethod.HEADrequest for the given URI.- Parameters:
uri- The URI- Returns:
- The
MutableHttpRequestinstance - See Also:
HttpRequestFactory
-
POST
static <T> MutableHttpRequest<T> POST(java.net.URI uri, T body)
Return aMutableHttpRequestthat executes anHttpMethod.POSTrequest 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
MutableHttpRequestinstance - See Also:
HttpRequestFactory
-
POST
static <T> MutableHttpRequest<T> POST(java.lang.String uri, T body)
Return aMutableHttpRequestthat executes anHttpMethod.POSTrequest 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
MutableHttpRequestinstance - See Also:
HttpRequestFactory
-
PUT
static <T> MutableHttpRequest<T> PUT(java.net.URI uri, T body)
Return aMutableHttpRequestthat executes anHttpMethod.PUTrequest 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
MutableHttpRequestinstance - See Also:
HttpRequestFactory
-
PUT
static <T> MutableHttpRequest<T> PUT(java.lang.String uri, T body)
Return aMutableHttpRequestthat executes anHttpMethod.PUTrequest 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
MutableHttpRequestinstance - See Also:
HttpRequestFactory
-
PATCH
static <T> MutableHttpRequest<T> PATCH(java.net.URI uri, T body)
Return aMutableHttpRequestthat executes anHttpMethod.PATCHrequest 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
MutableHttpRequestinstance - See Also:
HttpRequestFactory
-
PATCH
static <T> MutableHttpRequest<T> PATCH(java.lang.String uri, T body)
Return aMutableHttpRequestthat executes anHttpMethod.PATCHrequest 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
MutableHttpRequestinstance - See Also:
HttpRequestFactory
-
DELETE
static <T> MutableHttpRequest<T> DELETE(java.net.URI uri, T body)
Return aMutableHttpRequestthat executes anHttpMethod.DELETErequest 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
MutableHttpRequestinstance - See Also:
HttpRequestFactory
-
DELETE
static <T> MutableHttpRequest<T> DELETE(java.lang.String uri, T body)
Return aMutableHttpRequestthat executes anHttpMethod.DELETErequest 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
MutableHttpRequestinstance - See Also:
HttpRequestFactory
-
DELETE
static <T> MutableHttpRequest<T> DELETE(java.lang.String uri)
Return aMutableHttpRequestthat executes anHttpMethod.DELETErequest for the given URI.- Type Parameters:
T- The Http request type- Parameters:
uri- The URI- Returns:
- The
MutableHttpRequestinstance - See Also:
HttpRequestFactory
-
DELETE
static <T> MutableHttpRequest<T> DELETE(java.net.URI uri)
Return aMutableHttpRequestthat executes anHttpMethod.DELETErequest for the given URI.- Type Parameters:
T- The Http request type- Parameters:
uri- The URI- Returns:
- The
MutableHttpRequestinstance - See Also:
HttpRequestFactory
-
create
static <T> MutableHttpRequest<T> create(HttpMethod httpMethod, java.lang.String uri)
Create a newMutableHttpRequestfor 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 newMutableHttpRequestfor 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
-
-