Package org.restheart.exchange
Class Response<T>
java.lang.Object
org.restheart.exchange.Exchange<T>
org.restheart.exchange.Response<T>
- Type Parameters:
T- generic type
- Direct Known Subclasses:
ProxyResponse,ServiceResponse
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
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 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetContentType(io.undertow.server.HttpServerExchange exchange) getHeader(io.undertow.util.HttpString name) note: an header can have multiple values.note: an header can have multiple values.io.undertow.util.HeaderMapLogging MDC Context is bound to the thread.intstatic Responseof(io.undertow.server.HttpServerExchange exchange) voidsetContentType(String responseContentType) voidsets Content-Type=application/jsonvoidnote: an header can have multiple values.voidnote: an header can have multiple values.voidsetInError(int code, String message) abstract voidsetInError(int code, String message, Throwable t) voidsetMDCContext(Map<String, String> mdcCtx) voidsetStatusCode(int responseStatusCode) Methods inherited from class org.restheart.exchange.Exchange
getExchange, getWrappedExchange, isAccountInRole, isAuthenticated, isAuthenticated, isContentTypeFormOrMultipart, isContentTypeFormOrMultipart, isContentTypeJson, isContentTypeJson, isContentTypeText, isContentTypeXml, isInError, isInError, responseInterceptorsExecuted, setInError, setInError, setResponseInterceptorsExecuted, updateBufferSize
-
Constructor Details
-
Response
protected Response(io.undertow.server.HttpServerExchange exchange)
-
-
Method Details
-
of
-
getContentType
-
getContentType
- Specified by:
getContentTypein classExchange<T>- Returns:
- the responseContentType
-
setContentType
- 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
-
getHeaders
public io.undertow.util.HeaderMap getHeaders()- Returns:
- the response 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 response header
-
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 response 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
-
getMDCContext
Logging MDC Context is bound to the thread. In case of a thread switch it must be restored from response.getMDCContext() with MDC.setContextMap()- Returns:
- the MDC Context
-
setMDCContext
-
setInError
- Parameters:
code-message-t- can be null
-
setInError
- Parameters:
code-message-
-