Interface HttpResponse

All Known Implementing Classes:
HttpResponseImpl

public interface HttpResponse
Class representing an HTTP response. Contains details such as the status code, headers, and body.
  • Method Details

    • setHeader

      HttpResponse setHeader(HttpHeader name, String value)
      Sets a header for the response.
      Parameters:
      name - the header name as an enum
      value - the header value
    • setHeader

      HttpResponse setHeader(String name, String value)
      Sets a header for the response.
      Parameters:
      name - the header name as a string
      value - the header value
    • setBody

      HttpResponse setBody(ContentType contentType, String body)
      Sets the body of the response with a specific content type.
      Parameters:
      contentType - the content type
      body - the body as a string
    • setBody

      HttpResponse setBody(String contentType, String body)
      Sets the body of the response with a specific content type.
      Parameters:
      contentType - the content type as a string
      body - the body as a string
    • withStatus

      static HttpResponse withStatus(HttpStatusCode statusCode)
      Creates a new HTTP response with the specified status code and default message.
      Parameters:
      statusCode - the HTTP status code
      Returns:
      a new HttpResponse instance
    • withStatus

      static HttpResponse withStatus(int statusCode, String statusMessage)
      Creates a new HTTP response with the specified status code and message.
      Parameters:
      statusCode - the HTTP status code
      statusMessage - the HTTP status message
      Returns:
      a new HttpResponse instance
    • ok

      static HttpResponse ok()
      Creates a new HTTP response with the status code 200 (OK) and the specified body.
      Returns:
      a new HttpResponse instance
    • noContent

      static HttpResponse noContent()
      Creates a new HTTP response with the status code 500 (Internal Server Error) and the specified body.
      Returns:
      a new HttpResponse instance
    • notFound

      static HttpResponse notFound()
      Creates a new HTTP response with the status code 404 (Not Found) and the specified body.
      Returns:
      a new HttpResponse instance
    • badRequest

      static HttpResponse badRequest()
      Creates a new HTTP response with the status code 400 (Bad Request) and the specified body.
      Returns:
      a new HttpResponse instance
    • unexpectedError

      static HttpResponse unexpectedError()
      Creates a new HTTP response with the status code 500 (Internal Server Error) and the specified body.
      Returns:
      a new HttpResponse instance