Package kalix.javasdk

Class HttpResponse

Object
kalix.javasdk.HttpResponse

public class HttpResponse extends Object
Represents an HTTP response with more level control over the status code, content type and body.
  • Field Details

  • Method Details

    • getStatusCode

      public StatusCode.Success getStatusCode()
    • getContentType

      public String getContentType()
    • getBody

      public byte[] getBody()
    • ok

      public static HttpResponse ok()
      Creates a 200 OK response.
    • created

      public static HttpResponse created()
      Creates a 201 CREATED response.
    • accepted

      public static HttpResponse accepted()
      Creates a 202 ACCEPTED response.
    • noContent

      public static HttpResponse noContent()
      Creates a 204 NO CONTENT response.
    • ok

      public static HttpResponse ok(String text)
      Creates a 200 OK response with a text/plain body.
    • ok

      public static HttpResponse ok(Object object)
      Creates a 200 OK response with a application/json body. Object is encoded using Jackson serializer.
    • ok

      public static HttpResponse ok(byte[] body)
      Creates a 200 OK response with a application/octet-stream body.
    • of

      public static HttpResponse of(StatusCode.Success statusCode, String contentType, byte[] body)
      Creates an HTTP response with specified status code, content type and body.
      Parameters:
      statusCode - HTTP status code
      contentType - HTTP content type
      body - HTTP body
    • bodyAsJson

      public <T> T bodyAsJson(Class<T> clazz)
      Parses an HTTP body to a specified JSON type using Jackson deserializer.