Package 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 Description ServiceResponse()
ServiceResponse(JsonObject json)
ServiceResponse(ServiceResponse other)
ServiceResponse(Integer statusCode, String statusMessage, Buffer payload, MultiMap headers)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ServiceResponse
completedWithJson(Buffer json)
Creates aServiceResponse
with status code 200, status message OK, content typeapplication/json
andjson
as bodystatic ServiceResponse
completedWithJson(JsonArray jsonArray)
Creates aServiceResponse
with status code 200, status message OK, content typeapplication/json
andjsonArray
as bodystatic ServiceResponse
completedWithJson(JsonObject jsonObject)
Creates aServiceResponse
with status code 200, status message OK, content typeapplication/json
andjsonObject
as bodystatic ServiceResponse
completedWithPlainText(Buffer text)
Creates aServiceResponse
with status code 200, status message OK, content typetext/plain
andtext
as bodyMultiMap
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()
-
-
-
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 aServiceResponse
with status code 200, status message OK, content typeapplication/json
andjsonObject
as body- Parameters:
jsonObject
-- Returns:
-
completedWithJson
public static ServiceResponse completedWithJson(JsonArray jsonArray)
Creates aServiceResponse
with status code 200, status message OK, content typeapplication/json
andjsonArray
as body- Parameters:
jsonArray
-- Returns:
-
completedWithJson
public static ServiceResponse completedWithJson(Buffer json)
Creates aServiceResponse
with status code 200, status message OK, content typeapplication/json
andjson
as body- Parameters:
json
-- Returns:
-
completedWithPlainText
public static ServiceResponse completedWithPlainText(Buffer text)
Creates aServiceResponse
with status code 200, status message OK, content typetext/plain
andtext
as body- Parameters:
text
-- Returns:
-
-