Package org.restheart.exchange
Class Request<T>
- java.lang.Object
-
- org.restheart.exchange.Exchange<T>
-
- org.restheart.exchange.Request<T>
-
- Type Parameters:
T-
- Direct Known Subclasses:
ProxyRequest,ServiceRequest
public abstract class Request<T> extends Exchange<T>
The root class for implementing a Request providing the implementation for common methods- Author:
- Andrea Di Cesare <andrea@softinstigate.com>
-
-
Field Summary
Fields Modifier and Type Field Description static StringFORM_URLENCODEDstatic StringMULTIPARTstatic StringPATCHstatic StringSLASHstatic StringUNDERSCORE-
Fields inherited from class org.restheart.exchange.Exchange
APP_FORM_URLENCODED_TYPE, APPLICATION_PDF_TYPE, HAL_JSON_MEDIA_TYPE, IN_ERROR_KEY, JSON_MEDIA_TYPE, LOGGER, MAX_BUFFERS, MAX_CONTENT_SIZE, MULTIPART_FORM_DATA_TYPE, wrapped
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedRequest(io.undertow.server.HttpServerExchange exchange)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddXForwardedHeader(String key, String value)Add the header X-Forwarded-[key] to the proxied request; use it to pass to the backend information otherwise lost proxying the request.io.undertow.security.idm.AccountgetAuthenticatedAccount()StringgetContentType()static StringgetContentType(io.undertow.server.HttpServerExchange exchange)ExchangeKeys.METHODgetMethod()StringgetPath()PipelineInfogetPipelineInfo()LonggetStartTime()Map<String,List<String>>getXForwardedHeaders()booleanisContentTypeFormOrMultipart()static booleanisContentTypeFormOrMultipart(io.undertow.server.HttpServerExchange exchange)static booleanisContentTypeJson(io.undertow.server.HttpServerExchange exchange)helper method to check if the request content is JsonbooleanisDelete()helper method to check request methodbooleanisGet()helper method to check request methodbooleanisOptions()helper method to check request methodbooleanisPatch()helper method to check request methodbooleanisPost()helper method to check request methodbooleanisPut()helper method to check request methodstatic Requestof(io.undertow.server.HttpServerExchange exchange)protected voidsetContentLength(int length)voidsetContentType(String responseContentType)voidsetContentTypeAsJson()sets Content-Type=application/jsonvoidsetPipelineInfo(PipelineInfo pipelineInfo)voidsetStartTime(Long requestStartTime)-
Methods inherited from class org.restheart.exchange.Exchange
getExchange, getWrappedExchange, isAccountInRole, isAuthenticated, isAuthenticated, isContentTypeJson, isContentTypeText, isContentTypeXml, isInError, isInError, responseInterceptorsExecuted, setInError, setInError, setResponseInterceptorsExecuted, updateBufferSize
-
-
-
-
Field Detail
-
FORM_URLENCODED
public static final String FORM_URLENCODED
- See Also:
- Constant Field Values
-
MULTIPART
public static final String MULTIPART
- See Also:
- Constant Field Values
-
SLASH
public static final String SLASH
- See Also:
- Constant Field Values
-
PATCH
public static final String PATCH
- See Also:
- Constant Field Values
-
UNDERSCORE
public static final String UNDERSCORE
- See Also:
- Constant Field Values
-
-
Method Detail
-
of
public static Request of(io.undertow.server.HttpServerExchange exchange)
-
getContentType
public static String getContentType(io.undertow.server.HttpServerExchange exchange)
-
getPath
public String getPath()
-
getMethod
public ExchangeKeys.METHOD getMethod()
- Returns:
- the request method
-
getContentType
public String getContentType()
- Specified by:
getContentTypein classExchange<T>- Returns:
- the request ContentType
-
setContentType
public void setContentType(String responseContentType)
- Parameters:
responseContentType- the responseContentType to set
-
setContentTypeAsJson
public void setContentTypeAsJson()
sets Content-Type=application/json
-
setContentLength
protected void setContentLength(int length)
-
getStartTime
public Long getStartTime()
- Returns:
- the requestStartTime
-
setStartTime
public void setStartTime(Long requestStartTime)
- Parameters:
requestStartTime- the requestStartTime to set
-
getAuthenticatedAccount
public io.undertow.security.idm.Account getAuthenticatedAccount()
- Returns:
- the authenticatedAccount
-
addXForwardedHeader
public void addXForwardedHeader(String key, String value)
Add the header X-Forwarded-[key] to the proxied request; use it to pass to the backend information otherwise lost proxying the request.- Parameters:
key-value-
-
getPipelineInfo
public PipelineInfo getPipelineInfo()
- Returns:
- the PipelineInfo that allows to know which pipeline (service, proxy or static resource) is handling the exchange
-
setPipelineInfo
public void setPipelineInfo(PipelineInfo pipelineInfo)
- Parameters:
pipelineInfo- the pipelineInfo to set
-
isContentTypeJson
public static boolean isContentTypeJson(io.undertow.server.HttpServerExchange exchange)
helper method to check if the request content is Json- Parameters:
exchange-- Returns:
- true if Content-Type request header is application/json
-
isContentTypeFormOrMultipart
public static boolean isContentTypeFormOrMultipart(io.undertow.server.HttpServerExchange exchange)
-
isContentTypeFormOrMultipart
public boolean isContentTypeFormOrMultipart()
-
isDelete
public boolean isDelete()
helper method to check request method- Returns:
- true if method is METHOD.DELETE
-
isGet
public boolean isGet()
helper method to check request method- Returns:
- true if method is METHOD.GET
-
isOptions
public boolean isOptions()
helper method to check request method- Returns:
- true if method is METHOD.OPTIONS
-
isPatch
public boolean isPatch()
helper method to check request method- Returns:
- true if method is METHOD.PATCH
-
isPost
public boolean isPost()
helper method to check request method- Returns:
- true if method is METHOD.POST
-
isPut
public boolean isPut()
helper method to check request method- Returns:
- true if method is METHOD.PUT
-
-