Interface SmallResponse

All Superinterfaces:
AutoCloseable
All Known Implementing Classes:
SmallResponse.GenericSmallResponse

public interface SmallResponse extends AutoCloseable
Generic response object for Small.
Since:
1.1.0, 1.2.1, implements AutoCloseable, 1.4.0, is an interface. See SmallResponse.GenericSmallResponse for implementation.
Author:
Matthew Tropiano
  • Method Details

    • getStatus

      int getStatus()
      Returns:
      the response HTTP status code.
    • getHeaders

      Map<String,List<String>> getHeaders()
      Returns:
      the header map for adding headers to the response.
    • getContent

      Object getContent()
      Returns:
      the response content.
    • close

      default void close() throws Exception
      Specified by:
      close in interface AutoCloseable
      Throws:
      Exception
    • create

      static SmallResponse.GenericSmallResponse create(int status)
      Creates a new response with a default status.
      Parameters:
      status - the HTTP status to send.
      Returns:
      a new response.
    • create

      static SmallResponse.GenericSmallResponse create(int status, Object content)
      Creates a new response with status and content.
      Parameters:
      status - the HTTP status to send.
      content - the content object.
      Returns:
      a new response.
    • create

      static SmallResponse.GenericSmallResponse create(Object content)
      Creates a new response with 200 OK status and content.
      Parameters:
      content - the content object.
      Returns:
      a new response.
    • create

      static SmallResponse.GenericSmallResponse create(Object model, String viewName)
      Creates a new response with 200 OK status and a model-view driven content.
      Parameters:
      model - the model to render.
      viewName - the name of the view to resolve and use.
      Returns:
      a new response.
    • create

      static SmallResponse.GenericSmallResponse create(int status, Object model, String viewName)
      Creates a new response with 200 OK status and a model-view driven content.
      Parameters:
      status - the HTTP status to send.
      model - the model to render.
      viewName - the name of the view to resolve and use.
      Returns:
      a new response.
    • create

      static SmallResponse.GenericSmallResponse create(SmallResponse smallResponse)
      Creates a new response from another SmallResponse, copying the status, content, and the headers.
      Parameters:
      smallResponse - the source SmallResponse.
      Returns:
      a new response.