Package org.restheart.exchange
Class Exchange<T>
java.lang.Object
org.restheart.exchange.Exchange<T>
- Type Parameters:
T- generic type
The root class in the exchange hierarchy. An exchange wraps undertow
HttpServerExchange to provide simplified access to elements of the request
and of the response, such as query parameters, headers and content
- Author:
- Andrea Di Cesare <andrea@softinstigate.com>
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final StringSupported content type HALprotected static final io.undertow.util.AttachmentKey<Boolean> static final String* Supported content type JSONstatic intstatic final intstatic final Stringstatic final Stringprotected final io.undertow.server.HttpServerExchange -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract Stringio.undertow.server.HttpServerExchangeprotected io.undertow.server.HttpServerExchangebooleanisAccountInRole(String role) helper method to check if authenticated account is in the specified rolebooleanhelper method to check if request is authenticatedstatic booleanisAuthenticated(io.undertow.server.HttpServerExchange exchange) booleanstatic booleanisContentTypeFormOrMultipart(io.undertow.server.HttpServerExchange exchange) booleanhelper method to check if the request content is Jsonstatic booleanisContentTypeJson(io.undertow.server.HttpServerExchange exchange) helper method to check if the request content is Jsonbooleanhelper method to check if the request content is textbooleanhelper method to check if the request content is Xmbooleanstatic booleanisInError(io.undertow.server.HttpServerExchange exchange) static booleanresponseInterceptorsExecuted(io.undertow.server.HttpServerExchange exchange) voidsetInError(boolean inError) static voidsetInError(io.undertow.server.HttpServerExchange exchange) static voidsetResponseInterceptorsExecuted(io.undertow.server.HttpServerExchange exchange) static voidupdateBufferSize(int bufferSize)
-
Field Details
-
HAL_JSON_MEDIA_TYPE
Supported content type HAL- See Also:
-
JSON_MEDIA_TYPE
* Supported content type JSON- See Also:
-
APPLICATION_PDF_TYPE
- See Also:
-
TEXT_PLAIN_CONTENT_TYPE
- See Also:
-
FORM_URLENCODED
- See Also:
-
MULTIPART
- See Also:
-
IN_ERROR_KEY
-
MAX_CONTENT_SIZE
public static final int MAX_CONTENT_SIZE- See Also:
-
MAX_BUFFERS
public static int MAX_BUFFERS -
wrapped
protected final io.undertow.server.HttpServerExchange wrapped
-
-
Constructor Details
-
Exchange
public Exchange(io.undertow.server.HttpServerExchange exchange)
-
-
Method Details
-
updateBufferSize
public static void updateBufferSize(int bufferSize) -
getWrappedExchange
protected io.undertow.server.HttpServerExchange getWrappedExchange()- Returns:
- the wrapped HttpServerExchange
-
isInError
public static boolean isInError(io.undertow.server.HttpServerExchange exchange) -
isAuthenticated
public static boolean isAuthenticated(io.undertow.server.HttpServerExchange exchange) -
setInError
public static void setInError(io.undertow.server.HttpServerExchange exchange) -
responseInterceptorsExecuted
public static boolean responseInterceptorsExecuted(io.undertow.server.HttpServerExchange exchange) -
setResponseInterceptorsExecuted
public static void setResponseInterceptorsExecuted(io.undertow.server.HttpServerExchange exchange) -
getExchange
public io.undertow.server.HttpServerExchange getExchange() -
getContentType
-
isContentTypeJson
public boolean isContentTypeJson()helper method to check if the request content is Json- Returns:
- true if Content-Type request header is application/json
-
isInError
public boolean isInError()- Returns:
- true if request is errored
-
setInError
public void setInError(boolean inError) - Parameters:
inError- the inError to set
-
isContentTypeXml
public boolean isContentTypeXml()helper method to check if the request content is Xm- Returns:
- true if Content-Type request header is application/xml or text/xml
-
isContentTypeText
public boolean isContentTypeText()helper method to check if the request content is text- Returns:
- true if Content-Type request header starts with text/
-
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() -
isAuthenticated
public boolean isAuthenticated()helper method to check if request is authenticated- Returns:
- true if request is authenticated
-
isAccountInRole
helper method to check if authenticated account is in the specified role- Parameters:
role-- Returns:
-