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

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 <[email protected]>
  • Constructor Details

    • Response

      protected Response(io.undertow.server.HttpServerExchange exchange)
  • Method Details

    • 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:
      getContentType in class Exchange<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
    • getHeaders

      public io.undertow.util.HeaderMap getHeaders()
      Returns:
      the response headers
    • getHeader

      public String getHeader(io.undertow.util.HttpString name)
      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

      public String getHeader(String name)
      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

      public void setHeader(io.undertow.util.HttpString name, String value)
      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

      public void setHeader(String name, String value)
      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

      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
    • setMDCContext

      public void setMDCContext(Map<String,String> mdcCtx)
    • 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 -