Interface ResponseModel

All Known Implementing Classes:
ResponseModel.MapResponseModel, ResponseModel.TemplateResponseModel

public interface ResponseModel
A Response model contains information the server can use to provide a full HTTP response for a request handled by a RequestHandler.
Since:
2.1.0
  • Field Details

    • KEY_PROBLEM_TYPE

      static final String KEY_PROBLEM_TYPE
      Entry key for the problem type. Reserved for internal use.
      See Also:
    • KEY_PROBLEM_TITLE

      static final String KEY_PROBLEM_TITLE
      Entry key for the problem title. Reserved for internal use.
      See Also:
  • Method Details

    • getViewData

      Map<String,Object> getViewData()
      Returns:
      the view data associated with a HTTP response
    • mapResponseModel

      static ResponseModel.MapResponseModel mapResponseModel(Map<String,Object> viewData)
      Create a Map-based response model.
      Parameters:
      viewData - the model data associated with the view
      Returns:
      the MapResponseModel for the given view data
    • templateResponseModel

      static ResponseModel.TemplateResponseModel templateResponseModel(Map<String,Object> viewData, String template)
      Create a template response model.
      Parameters:
      viewData - the model data associated with the view
      template - the HTML template to use to render a response, if needed
      Returns:
      the TemplateResponseModel for the given view data and template
    • problemResponseModel

      static ResponseModel problemResponseModel(String type)
      Create a problem response model, with information about an existing problem.

      See RFC 7807 for the field semantics.

      Note that setting this information doesn't necessarily imply that the response will use the application/problem+json media type.

      Parameters:
      type - The problem type
      Returns:
      a new ResponseModel with the defined information.
      Since:
      5.4.0
    • problemResponseModel

      static ResponseModel problemResponseModel(String type, String title)
      Create a problem response model, with information about an existing problem.

      See RFC 7807 for the field semantics.

      Note that setting this information doesn't necessarily imply that the response will use the application/problem+json media type.

      Parameters:
      type - The problem type
      title - The problem title
      Returns:
      a new ResponseModel with the defined information.
      Since:
      5.4.0
    • problemResponseModel

      static ResponseModel problemResponseModel(String template, String type, String title)
      Create a problem response model, with information about an existing problem.

      See RFC 7807 for the field semantics.

      Note that setting this information doesn't necessarily imply that the response will use the application/problem+json media type.

      Parameters:
      template - The HTML template or HAAPI representation function to use to render a response, if needed
      type - The problem type
      title - The problem title
      Returns:
      a new ResponseModel with the defined information.
      Since:
      5.4.0