Package org.restheart.exchange
Class UninitializedRequest
UninitializedRequest wraps the exchage and provides access to
request attributes (such as getPath()) and allows
setting a customRequestInitializer
The request content can be only accessed in raw format
with getRawContent() and setRawContent()
Interceptors at intercePoint REQUEST_BEFORE_EXCHANGE_INIT
receive UninitializedRequest as request argument
-
Field Summary
Fields inherited from class org.restheart.exchange.ServiceRequest
content, CONTENT_INJECTEDFields inherited from class org.restheart.exchange.Request
PATCH, PIPELINE_INFO_KEY, SLASH, UNDERSCOREFields inherited from class org.restheart.exchange.Exchange
APPLICATION_PDF_TYPE, FORM_URLENCODED, HAL_JSON_MEDIA_TYPE, IN_ERROR_KEY, JSON_MEDIA_TYPE, MAX_BUFFERS, MAX_CONTENT_SIZE, MULTIPART, TEXT_PLAIN_CONTENT_TYPE, wrapped -
Method Summary
Modifier and TypeMethodDescriptionConsumer<io.undertow.server.HttpServerExchange> throws IllegalStateException the content can only be retrieved in raw format, use getRawContent()byte[]static UninitializedRequestof(io.undertow.server.HttpServerExchange exchange) Parses the content from the exchange and converts it into an instance of the specified typeT.voidsetContent(Object content) throws IllegalStateException the content can only be set in raw format, use setRawContent()voidsetCustomRequestInitializer(Consumer<io.undertow.server.HttpServerExchange> customRequestInitializer) If a customRequestInitializer is set (not null), the ServiceExchangeInitializer will delegate to customRequestInitializer.accept(exchange) the responsability to initialize the requestvoidsetRawContent(byte[] data) overwrite the request body raw bytes make sense to invoke it before request initializationMethods inherited from class org.restheart.exchange.ServiceRequest
isContentInjected, isHandledBy, of, setContentInjectedMethods inherited from class org.restheart.exchange.Request
addXForwardedHeader, blockForTooManyRequests, getAuthenticatedAccount, getContentType, getContentType, getCookie, getHeader, getHeaders, getMethod, getPath, getPathParam, getPathParams, getPipelineInfo, getPipelineInfo, getQueryParameterOfDefault, getQueryParameterOrDefault, getQueryParameters, getQueryString, getRequestContentLength, getStartTime, getURL, getXForwardedHeaders, isAuthenticated, isBlockForTooManyRequests, isDelete, isGet, isOptions, isPatch, isPost, isPut, pipelineInfo, setContentLength, setContentType, setContentTypeAsJson, setHeader, setHeader, setPipelineInfo, setPipelineInfo, setStartTimeMethods inherited from class org.restheart.exchange.Exchange
getExchange, getWrappedExchange, isAccountInRole, isAuthenticated, isContentTypeFormOrMultipart, isContentTypeFormOrMultipart, isContentTypeJson, isContentTypeJson, isContentTypeText, isContentTypeXml, isInError, isInError, responseInterceptorsExecuted, setInError, setInError, setResponseInterceptorsExecuted, updateBufferSize
-
Method Details
-
of
-
getContent
throws IllegalStateException the content can only be retrieved in raw format, use getRawContent()- Overrides:
getContentin classServiceRequest<Object>- Returns:
-
setContent
throws IllegalStateException the content can only be set in raw format, use setRawContent()- Overrides:
setContentin classServiceRequest<Object>- Parameters:
content-
-
getRawContent
public byte[] getRawContent()- Returns:
- the request body raw bytes
-
setRawContent
overwrite the request body raw bytes make sense to invoke it before request initialization- Parameters:
data-- Throws:
IOException
-
setCustomRequestInitializer
public void setCustomRequestInitializer(Consumer<io.undertow.server.HttpServerExchange> customRequestInitializer) If a customRequestInitializer is set (not null), the ServiceExchangeInitializer will delegate to customRequestInitializer.accept(exchange) the responsability to initialize the request- Parameters:
customRequestInitializer-
-
customRequestInitializer
- Returns:
- the custom Consumer used to initialize the request in place of the Service default one
-
parseContent
Description copied from class:ServiceRequestParses the content from the exchange and converts it into an instance of the specified typeT. This method retrieves data from the exchange, interprets it according to the expected format, and attempts to convert this data into an object of typeT.- Specified by:
parseContentin classServiceRequest<Object>- Returns:
- an instance of
Trepresenting the parsed content - Throws:
IOException- if an IO error occursBadRequestException- if the content does not match the expected format for typeT
-