Package org.restheart.exchange
Class Request<T>
java.lang.Object
org.restheart.exchange.Exchange<T>
org.restheart.exchange.Request<T>
- Type Parameters:
T
- generic type
- Direct Known Subclasses:
ProxyRequest
,ServiceRequest
The root class for implementing a Request providing the implementation for
common methods
- Author:
- Andrea Di Cesare <[email protected]>
-
Field Summary
Modifier and TypeFieldDescriptionstatic String
static String
static String
static String
static String
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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
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.io.undertow.security.idm.Account
static String
getContentType(io.undertow.server.HttpServerExchange exchange)
io.undertow.server.handlers.Cookie
note: an header can have multiple values.io.undertow.util.HeaderMap
getPath()
getPathParam(String pathTemplate, String paramName)
get a path parameter using a path template eg pathTemplate=/foo/{id}, paramName=id and URI=/foo/bar => returns bargetPathParams(String pathTemplate)
get path parameters using a template pathTemplate=/foo/{id} and URI=/foo/bar => returns a map with id=bargetQueryParameterOfDefault(String name, String defaultValue)
long
getURL()
boolean
static boolean
isContentTypeFormOrMultipart(io.undertow.server.HttpServerExchange exchange)
static boolean
isContentTypeJson(io.undertow.server.HttpServerExchange exchange)
helper method to check if the request content is Jsonboolean
isDelete()
helper method to check request methodboolean
isGet()
helper method to check request methodboolean
helper method to check request methodboolean
isPatch()
helper method to check request methodboolean
isPost()
helper method to check request methodboolean
isPut()
helper method to check request methodstatic Request
of(io.undertow.server.HttpServerExchange exchange)
static PipelineInfo
pipelineInfo(io.undertow.server.HttpServerExchange exchange)
protected void
setContentLength(int length)
void
setContentType(String responseContentType)
void
sets Content-Type=application/jsonvoid
note: an header can have multiple values.void
note: an header can have multiple values.static void
setPipelineInfo(io.undertow.server.HttpServerExchange exchange, PipelineInfo pipelineInfo)
void
setPipelineInfo(PipelineInfo pipelineInfo)
void
setStartTime(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 Details
-
FORM_URLENCODED
- See Also:
- Constant Field Values
-
MULTIPART
- See Also:
- Constant Field Values
-
SLASH
- See Also:
- Constant Field Values
-
PATCH
- See Also:
- Constant Field Values
-
UNDERSCORE
- See Also:
- Constant Field Values
-
-
Constructor Details
-
Request
protected Request(io.undertow.server.HttpServerExchange exchange)
-
-
Method Details
-
of
-
getContentType
-
getPath
- Returns:
- the request path
-
getURL
- Returns:
- the request URL
-
getQueryString
- Returns:
- the query string
-
getMethod
- Returns:
- the request method
-
getRequestContentLength
public long getRequestContentLength()- Returns:
- a content lenght
-
getQueryParameters
- Returns:
- a mutable map of query parameters
-
getQueryParameterOfDefault
- Returns:
- a the first value of the query paramter of defaultValue if not present
-
getHeaders
public io.undertow.util.HeaderMap getHeaders()- Returns:
- the request headers
-
getHeader
note: an header can have multiple values. This only returns the first one. use getHeaders() to get all the header's values- Parameters:
name
- the name of the header to return- Returns:
- the first value of the header
-
setHeader
note: an header can have multiple values. This sets the given value clearing existing ones. use getHeaders().add(value) to add the value without clearing.- Parameters:
name
- the name of the header to return
-
setHeader
note: an header can have multiple values. This sets the given value clearing existing ones. use getHeaders().add(value) to add the value without clearing.- Parameters:
name
- the name of the header to return
-
getCookie
- Parameters:
name
- the name of the cookie to return- Returns:
- a the cookie
-
getPathParams
get path parameters using a template pathTemplate=/foo/{id} and URI=/foo/bar => returns a map with id=bar- Parameters:
pathTemplate
- the path template- Returns:
- the path parameters
-
getPathParam
get a path parameter using a path template eg pathTemplate=/foo/{id}, paramName=id and URI=/foo/bar => returns bar- Parameters:
pathTemplate
- the path templateparamName
- name of parameter- Returns:
- the path parameter
-
getContentType
- Specified by:
getContentType
in classExchange<T>
- Returns:
- the request ContentType
-
setContentType
- Parameters:
responseContentType
- the responseContentType to set
-
setContentTypeAsJson
public void setContentTypeAsJson()sets Content-Type=application/json -
setContentLength
protected void setContentLength(int length) -
getStartTime
- Returns:
- the requestStartTime
-
setStartTime
- Parameters:
requestStartTime
- the requestStartTime to set
-
getAuthenticatedAccount
public io.undertow.security.idm.Account getAuthenticatedAccount()- Returns:
- the authenticatedAccount
-
addXForwardedHeader
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
-
-
getXForwardedHeaders
-
pipelineInfo
- Returns:
- the PipelineInfo that allows to know which pipeline (service, proxy or static resource) is handling the exchange
-
setPipelineInfo
public static void setPipelineInfo(io.undertow.server.HttpServerExchange exchange, PipelineInfo pipelineInfo)- Parameters:
exchange
- the exchange to bind the pipelineInfo topipelineInfo
- the pipelineInfo to set
-
getPipelineInfo
- Returns:
- the PipelineInfo that allows to know which pipeline (service, proxy or static resource) is handling the exchange
-
setPipelineInfo
- 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
-