Class Response

java.lang.Object
com.codingchili.core.protocol.Response

public abstract class Response extends Object
Helper methods for creating response messages.

Response messages should always contain a reference to the request.

  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static io.vertx.core.json.JsonObject
    addHeaders​(String target, String route, io.vertx.core.json.JsonObject message)
    Adds response headers for a request.
    static io.vertx.core.buffer.Buffer
    buffer​(Object message)
     
    static io.vertx.core.buffer.Buffer
    buffer​(String target, String route, Object message)
    Converts the given message into a serializable format used to send messages back to clients.
    static io.vertx.core.json.JsonObject
    error​(String target, String route, ResponseStatus status, Throwable e)
    Creates a response object given a response status and a throwable.
    static io.vertx.core.json.JsonObject
    json​(Object message)
     
    static io.vertx.core.json.JsonObject
    json​(String target, String route, Object message)
    Creates a json response message.
    static io.vertx.core.json.JsonObject
    status​(String target, String route, ResponseStatus status)
    Creates a response object given a response status.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Response

      public Response()
  • Method Details

    • status

      public static io.vertx.core.json.JsonObject status(String target, String route, ResponseStatus status)
      Creates a response object given a response status.
      Parameters:
      target - the target header to set for the response.
      route - the route header to set for the response.
      status - the status to create the response from.
      Returns:
      a JSON encoded response packed in a buffer.
    • error

      public static io.vertx.core.json.JsonObject error(String target, String route, ResponseStatus status, Throwable e)
      Creates a response object given a response status and a throwable.
      Parameters:
      target - the target header to set for the response.
      route - the route header to set for the response.
      status - the status to include in the response.
      e - an exception that was the cause of an abnormal response status.
      Returns:
      a JSON encoded response packed in a buffer.
    • buffer

      public static io.vertx.core.buffer.Buffer buffer(Object message)
      Parameters:
      message - the message to be converted to a buffer.
      Returns:
      a message buffer.
      See Also:
      buffer(Object)
    • buffer

      public static io.vertx.core.buffer.Buffer buffer(String target, String route, Object message)
      Converts the given message into a serializable format used to send messages back to clients. Use this method when the context of a request is not available.
      Parameters:
      message - the message to be converted.
      target - the target header to set for the response.
      route - the route header to set for the response.
      Returns:
      a sendable json object without headers.
    • json

      public static io.vertx.core.json.JsonObject json(Object message)
      Parameters:
      message - an object to be converted to a json message.
      Returns:
      a json message with headers set.
      See Also:
      json(Object)
    • json

      public static io.vertx.core.json.JsonObject json(String target, String route, Object message)
      Creates a json response message.
      Parameters:
      target - the target header to set for the response.
      route - the route header to set for the response.
      message - the message to add request headers to.
      Returns:
      a json object.
    • addHeaders

      public static io.vertx.core.json.JsonObject addHeaders(String target, String route, io.vertx.core.json.JsonObject message)
      Adds response headers for a request.
      Parameters:
      target - the target header to set for the response.
      route - the route header to set for the response.
      message - the response json object.
      Returns:
      a json object with headers from the request added.