Package io.micronaut.http.poja
Class PojaHttpRequest<B,REQ,RES>
java.lang.Object
io.micronaut.http.poja.PojaHttpRequest<B,REQ,RES>
- Type Parameters:
B
- The body typeREQ
- The POJA request typeRES
- The POJA response type
- All Implemented Interfaces:
io.micronaut.core.attr.AttributeHolder
,io.micronaut.core.attr.MutableAttributeHolder
,io.micronaut.core.convert.ConversionServiceAware
,io.micronaut.http.HttpMessage<B>
,io.micronaut.http.HttpRequest<B>
,io.micronaut.http.MutableHttpMessage<B>
,io.micronaut.http.MutableHttpRequest<B>
,io.micronaut.http.ServerHttpRequest<B>
,ServletExchange<REQ,
,RES> ServletHttpRequest<REQ,
B>
- Direct Known Subclasses:
ApacheServletHttpRequest
public abstract class PojaHttpRequest<B,REQ,RES>
extends Object
implements ServletHttpRequest<REQ,B>, io.micronaut.http.ServerHttpRequest<B>, ServletExchange<REQ,RES>, io.micronaut.http.MutableHttpRequest<B>
A base class for serverless POJA requests that provides a number of common methods
to be reused for body and binding.
- Since:
- 4.10.0
- Author:
- Andriy
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.micronaut.servlet.http.ServletHttpRequest
ServletHttpRequest.AsyncExecution, ServletHttpRequest.AsyncExecutionCallback
-
Field Summary
Modifier and TypeFieldDescriptionprotected final io.micronaut.core.convert.value.MutableConvertibleValues<Object>
protected final io.micronaut.http.codec.MediaTypeCodecRegistry
protected final io.micronaut.core.convert.ConversionService
static final io.micronaut.core.type.Argument<io.micronaut.core.convert.value.ConvertibleValues>
protected final PojaHttpResponse<?,
RES> Fields inherited from interface io.micronaut.http.HttpRequest
SCHEME_HTTP, SCHEME_HTTPS
-
Constructor Summary
ConstructorDescriptionPojaHttpRequest
(io.micronaut.core.convert.ConversionService conversionService, io.micronaut.http.codec.MediaTypeCodecRegistry codecRegistry, PojaHttpResponse<?, RES> response) -
Method Summary
Modifier and TypeMethodDescriptionabstract io.micronaut.http.body.ByteBody
byteBody()
<T> T
consumeBody
(Function<InputStream, T> consumer) A utility method that allows consuming body.@NonNull io.micronaut.core.convert.value.MutableConvertibleValues<Object>
<T> @NonNull Optional<T>
getBody
(@NonNull io.micronaut.core.convert.ArgumentConversionContext<T> conversionContext) protected io.micronaut.core.convert.value.ConvertibleMultiValues<CharSequence>
A method used for retrieving form data.Returns anInputStream
that can be used to read the body of this HTTP request.Returns aBufferedReader
that can be used to read the text body of this HTTP request.ServletHttpRequest<REQ,
? super Object> boolean
Whether the request body is a form.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.micronaut.core.attr.AttributeHolder
getAttribute, getAttribute
Methods inherited from interface io.micronaut.core.convert.ConversionServiceAware
setConversionService
Methods inherited from interface io.micronaut.http.HttpMessage
getBody, getBody, getBody, getBodyWriter, getCharacterEncoding, getContentLength, getContentType
Methods inherited from interface io.micronaut.http.HttpRequest
accept, getCertificate, getCookies, getHttpVersion, getLocale, getMethod, getMethodName, getOrigin, getPath, getRemoteAddress, getServerAddress, getServerName, getSslSession, getUri, getUserPrincipal, getUserPrincipal, isSecure, mutate, setAttribute
Methods inherited from interface io.micronaut.core.attr.MutableAttributeHolder
removeAttribute
Methods inherited from interface io.micronaut.http.MutableHttpMessage
bodyWriter
Methods inherited from interface io.micronaut.http.MutableHttpRequest
accept, accept, basicAuth, bearerAuth, body, contentEncoding, contentLength, contentType, contentType, cookie, cookies, getHeaders, getParameters, header, headers, headers, uri, uri
Methods inherited from interface io.micronaut.servlet.http.ServletHttpRequest
executeAsync, getContextPath, getNativeRequest, isAsyncSupported
-
Field Details
-
CONVERTIBLE_VALUES_ARGUMENT
public static final io.micronaut.core.type.Argument<io.micronaut.core.convert.value.ConvertibleValues> CONVERTIBLE_VALUES_ARGUMENT -
conversionService
protected final io.micronaut.core.convert.ConversionService conversionService -
codecRegistry
protected final io.micronaut.http.codec.MediaTypeCodecRegistry codecRegistry -
attributes
-
response
-
-
Constructor Details
-
PojaHttpRequest
public PojaHttpRequest(io.micronaut.core.convert.ConversionService conversionService, io.micronaut.http.codec.MediaTypeCodecRegistry codecRegistry, PojaHttpResponse<?, RES> response)
-
-
Method Details
-
byteBody
public abstract io.micronaut.http.body.ByteBody byteBody()- Specified by:
byteBody
in interfaceio.micronaut.http.ServerHttpRequest<B>
-
getAttributes
@NonNull public @NonNull io.micronaut.core.convert.value.MutableConvertibleValues<Object> getAttributes()- Specified by:
getAttributes
in interfaceio.micronaut.core.attr.AttributeHolder
- Specified by:
getAttributes
in interfaceio.micronaut.http.HttpMessage<B>
- Specified by:
getAttributes
in interfaceio.micronaut.core.attr.MutableAttributeHolder
-
consumeBody
A utility method that allows consuming body.- Type Parameters:
T
- The function return value- Parameters:
consumer
- The method to consume the body- Returns:
- The result
-
getBody
@NonNull public <T> @NonNull Optional<T> getBody(@NonNull @NonNull io.micronaut.core.convert.ArgumentConversionContext<T> conversionContext) - Specified by:
getBody
in interfaceio.micronaut.http.HttpMessage<B>
-
getFormData
A method used for retrieving form data. Can be overridden by specific implementations.- Returns:
- The form data as multi-values.
-
getInputStream
Description copied from interface:ServletHttpRequest
Returns anInputStream
that can be used to read the body of this HTTP request. This method is typically used to read binary data. If the body is text, theServletHttpRequest.getReader()
method is more appropriate.- Specified by:
getInputStream
in interfaceServletHttpRequest<B,
REQ> - Returns:
- The input stream
-
getReader
Description copied from interface:ServletHttpRequest
Returns aBufferedReader
that can be used to read the text body of this HTTP request.- Specified by:
getReader
in interfaceServletHttpRequest<B,
REQ> - Returns:
- The reader
-
isFormSubmission
public boolean isFormSubmission()Whether the request body is a form.- Returns:
- Whether it is a form submission
-
getRequest
- Specified by:
getRequest
in interfaceServletExchange<B,
REQ> - Returns:
- The request object
-
getResponse
- Specified by:
getResponse
in interfaceServletExchange<B,
REQ> - Returns:
- The response object
-