Class JsonProxyResponse

java.lang.Object
org.restheart.exchange.Exchange<com.google.gson.JsonElement>
org.restheart.exchange.Response<com.google.gson.JsonElement>
org.restheart.exchange.ProxyResponse<com.google.gson.JsonElement>
org.restheart.exchange.JsonProxyResponse
All Implemented Interfaces:
AutoCloseable, BufferedExchange<com.google.gson.JsonElement>

public class JsonProxyResponse extends ProxyResponse<com.google.gson.JsonElement>
Author:
Andrea Di Cesare <andrea@softinstigate.com>
  • Constructor Details

    • JsonProxyResponse

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

    • of

      public static JsonProxyResponse of(io.undertow.server.HttpServerExchange exchange)
    • readContent

      public com.google.gson.JsonElement readContent() throws IOException
      Description copied from interface: BufferedExchange
      reads data from the buffer converting it to T
      Specified by:
      readContent in interface BufferedExchange<com.google.gson.JsonElement>
      Specified by:
      readContent in class ProxyResponse<com.google.gson.JsonElement>
      Returns:
      the content as Json
      Throws:
      IOException
    • writeContent

      public void writeContent(com.google.gson.JsonElement content) throws IOException
      writes the response content allocates the PooledByteBuffer array so close() must be invoked to avoid memory leaks
      Specified by:
      writeContent in interface BufferedExchange<com.google.gson.JsonElement>
      Specified by:
      writeContent in class ProxyResponse<com.google.gson.JsonElement>
      Parameters:
      content -
      Throws:
      IOException
    • getErrorContent

      protected com.google.gson.JsonElement getErrorContent(int code, String httpStatusText, String message, Throwable t, boolean includeStackTrace) throws IOException
      Specified by:
      getErrorContent in class ProxyResponse<com.google.gson.JsonElement>
      Parameters:
      code -
      httpStatusText -
      message -
      t -
      includeStackTrace -
      Returns:
      the content descibing the error
      Throws:
      IOException