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 <[email protected]>
-
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
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
getContentType
(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.HeaderMap
Logging MDC Context is bind to the thread context.int
static Response
of
(io.undertow.server.HttpServerExchange exchange) 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.void
setInError
(int code, String message) abstract void
setInError
(int code, String message, Throwable t) void
setMDCContext
(Map<String, String> mdcCtx) void
setStatusCode
(int responseStatusCode) static Type
type()
Methods inherited from class org.restheart.exchange.Exchange
getExchange, getWrappedExchange, isAccountInRole, isAuthenticated, isAuthenticated, isContentTypeJson, isContentTypeText, isContentTypeXml, isInError, isInError, responseInterceptorsExecuted, setInError, setInError, setResponseInterceptorsExecuted, updateBufferSize
-
Constructor Details
-
Response
protected Response(io.undertow.server.HttpServerExchange exchange)
-
-
Method Details
-
of
-
type
-
getContentType
-
getContentType
- Specified by:
getContentType
in 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 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
-
setMDCContext
-
setInError
- Parameters:
code
-message
-t
- can be null
-
setInError
- Parameters:
code
-message
-
-