io.vertx.ext.web.api.service

## Class ServiceResponse

- java.lang.Object
- - io.vertx.ext.web.api.service.ServiceResponse

-     public class ServiceResponse
      extends Object

  Data object that encapsulates all informations about an HTTP Response

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ServiceResponse()`
    `ServiceResponse(Integer statusCode, String statusMessage, Buffer payload, MultiMap headers)`
    `ServiceResponse(JsonObject json)`
    `ServiceResponse(ServiceResponse other)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static ServiceResponse` | `completedWithJson(Buffer json)` Creates a `ServiceResponse` with status code 200, status message OK, content type `application/json` and `json` as body
    `static ServiceResponse` | `completedWithJson(JsonArray jsonArray)` Creates a `ServiceResponse` with status code 200, status message OK, content type `application/json` and `jsonArray` as body
    `static ServiceResponse` | `completedWithJson(JsonObject jsonObject)` Creates a `ServiceResponse` with status code 200, status message OK, content type `application/json` and `jsonObject` as body
    `static ServiceResponse` | `completedWithPlainText(Buffer text)` Creates a `ServiceResponse` with status code 200, status message OK, content type `text/plain` and `text` as body
    `MultiMap` | `getHeaders()`
    `Buffer` | `getPayload()`
    `Integer` | `getStatusCode()`
    `String` | `getStatusMessage()`
    `ServiceResponse` | `putHeader(String key, String value)`
    `ServiceResponse` | `setHeaders(MultiMap headers)`
    `ServiceResponse` | `setPayload(Buffer payload)`
    `ServiceResponse` | `setStatusCode(Integer statusCode)`
    `ServiceResponse` | `setStatusMessage(String statusMessage)`
    `JsonObject` | `toJson()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ServiceResponse

          public ServiceResponse()

    - #### ServiceResponse

          public ServiceResponse(JsonObject json)

    - #### ServiceResponse

          public ServiceResponse(Integer statusCode,
                                 String statusMessage,
                                 Buffer payload,
                                 MultiMap headers)

    - #### ServiceResponse

          public ServiceResponse(ServiceResponse other)

  - ### Method Detail

    - #### toJson

          public JsonObject toJson()

    - #### getStatusCode

          public Integer getStatusCode()

    - #### getStatusMessage

          public String getStatusMessage()

    - #### getPayload

          public Buffer getPayload()

    - #### getHeaders

          public MultiMap getHeaders()

    - #### setHeaders

          public ServiceResponse setHeaders(MultiMap headers)

    - #### setStatusCode

          public ServiceResponse setStatusCode(Integer statusCode)

    - #### setStatusMessage

          public ServiceResponse setStatusMessage(String statusMessage)

    - #### setPayload

          public ServiceResponse setPayload(Buffer payload)

    - #### putHeader

          public ServiceResponse putHeader(String key,
                                           String value)

    - #### completedWithJson

          public static ServiceResponse completedWithJson(JsonObject jsonObject)

      Creates a `ServiceResponse` with status code 200, status message OK, content type `application/json` and `jsonObject` as body
      Parameters:
        `jsonObject` -
      Returns:

    - #### completedWithJson

          public static ServiceResponse completedWithJson(JsonArray jsonArray)

      Creates a `ServiceResponse` with status code 200, status message OK, content type `application/json` and `jsonArray` as body
      Parameters:
        `jsonArray` -
      Returns:

    - #### completedWithJson

          public static ServiceResponse completedWithJson(Buffer json)

      Creates a `ServiceResponse` with status code 200, status message OK, content type `application/json` and `json` as body
      Parameters:
        `json` -
      Returns:

    - #### completedWithPlainText

          public static ServiceResponse completedWithPlainText(Buffer text)

      Creates a `ServiceResponse` with status code 200, status message OK, content type `text/plain` and `text` as body
      Parameters:
        `text` -
      Returns:

Copyright © 2023 Eclipse. All rights reserved.