Package org.restheart.exchange
Class Response<T>
- java.lang.Object
-
- org.restheart.exchange.Exchange<T>
-
- org.restheart.exchange.Response<T>
-
- Type Parameters:
T-
- Direct Known Subclasses:
ProxyResponse,ServiceResponse
public abstract class Response<T> extends Exchange<T>
The root class for implementing a Response providing the implementation for common methods- Author:
- Andrea Di Cesare <andrea@softinstigate.com>
-
-
Field Summary
-
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 protectedResponse(io.undertow.server.HttpServerExchange exchange)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description StringgetContentType()static StringgetContentType(io.undertow.server.HttpServerExchange exchange)Map<String,String>getMDCContext()Logging MDC Context is bind to the thread context.intgetStatusCode()static Responseof(io.undertow.server.HttpServerExchange exchange)voidsetContentType(String responseContentType)voidsetContentTypeAsJson()sets Content-Type=application/jsonvoidsetInError(int code, String message)abstract voidsetInError(int code, String message, Throwable t)voidsetMDCContext(Map<String,String> mdcCtx)voidsetStatusCode(int responseStatusCode)static Typetype()-
Methods inherited from class org.restheart.exchange.Exchange
getExchange, getWrappedExchange, isAccountInRole, isAuthenticated, isAuthenticated, isContentTypeJson, isContentTypeText, isContentTypeXml, isInError, isInError, responseInterceptorsExecuted, setInError, setInError, setResponseInterceptorsExecuted, updateBufferSize
-
-
-
-
Method Detail
-
of
public static Response of(io.undertow.server.HttpServerExchange exchange)
-
type
public static Type type()
-
getContentType
public static String getContentType(io.undertow.server.HttpServerExchange exchange)
-
getContentType
public String getContentType()
- Specified by:
getContentTypein classExchange<T>- Returns:
- the responseContentType
-
setContentType
public void setContentType(String responseContentType)
- Parameters:
responseContentType- the responseContentType to set
-
setContentTypeAsJson
public void setContentTypeAsJson()
sets Content-Type=application/json
-
getStatusCode
public int getStatusCode()
- Returns:
- the responseStatusCode of -1 if not set
-
setStatusCode
public void setStatusCode(int responseStatusCode)
- Parameters:
responseStatusCode- the responseStatusCode to set
-
getMDCContext
public Map<String,String> getMDCContext()
Logging MDC Context is bind to the thread context. In case of a thread switch it must be restored from this exchange attachment using MDC.setContextMap()- Returns:
- the MDC Context
-
setInError
public abstract void setInError(int code, String message, Throwable t)- Parameters:
code-message-t- can be null
-
setInError
public void setInError(int code, String message)- Parameters:
code-message-
-
-