Package kos.core
Interface Response
-
- All Known Implementing Classes:
EmptyResponse,RawResponse,SerializableResponse
public interface ResponseRepresents a (mutable object) response to be sent to the http client.
-
-
Field Summary
Fields Modifier and Type Field Description static ResponseACCEPTEDstatic ResponseBAD_GATEWAYstatic ResponseBAD_REQUESTstatic ResponseCONFLICTstatic ResponseCREATEDstatic ResponseFORBIDDENstatic ResponseGATEWAY_TIMEOUTstatic ResponseGONEstatic ResponseMETHOD_NOT_ALLOWEDstatic ResponseNO_CONTENTstatic ResponseNOT_ACCEPTABLEstatic ResponseNOT_FOUNDstatic ResponseNOT_IMPLEMENTEDstatic ResponseSERVICE_UNAVAILABLEstatic ResponseTOO_MANY_REQUESTSstatic ResponseUNAUTHORIZED
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static Responseempty()Creates an empty response.static Responseempty(int statusCode)Creates an empty response for a givenstatusCode.Map<? extends CharSequence,? extends CharSequence>headers()Responseheaders(Map<? extends CharSequence,? extends CharSequence> value)static <T> Responseof(T payload)Wraps an object as a response.static <T> ResponseofNullable(T payload)Wraps a nullable object as a response.voidsend(io.vertx.core.http.HttpServerResponse response)static voidsend(io.vertx.ext.web.RoutingContext context, Object payload)Sends a response to the client.static voidsend(io.vertx.ext.web.RoutingContext context, Response response)Sends a response to the client.static voidsendDefaultNoContent(io.vertx.ext.web.RoutingContext context)Sends an empty response to the client.static voidsendError(io.vertx.ext.web.RoutingContext context, Throwable cause)Serializes aThrowableand sends as a response to the client.intstatusCode()ResponsestatusCode(int value)static Responsewrap(io.vertx.core.buffer.Buffer serialized)Wraps a Buffer into a response.
-
-
-
Field Detail
-
CREATED
static final Response CREATED
-
ACCEPTED
static final Response ACCEPTED
-
NO_CONTENT
static final Response NO_CONTENT
-
BAD_REQUEST
static final Response BAD_REQUEST
-
UNAUTHORIZED
static final Response UNAUTHORIZED
-
FORBIDDEN
static final Response FORBIDDEN
-
NOT_FOUND
static final Response NOT_FOUND
-
METHOD_NOT_ALLOWED
static final Response METHOD_NOT_ALLOWED
-
NOT_ACCEPTABLE
static final Response NOT_ACCEPTABLE
-
CONFLICT
static final Response CONFLICT
-
GONE
static final Response GONE
-
TOO_MANY_REQUESTS
static final Response TOO_MANY_REQUESTS
-
NOT_IMPLEMENTED
static final Response NOT_IMPLEMENTED
-
BAD_GATEWAY
static final Response BAD_GATEWAY
-
SERVICE_UNAVAILABLE
static final Response SERVICE_UNAVAILABLE
-
GATEWAY_TIMEOUT
static final Response GATEWAY_TIMEOUT
-
-
Method Detail
-
statusCode
int statusCode()
-
statusCode
Response statusCode(int value)
-
headers
Map<? extends CharSequence,? extends CharSequence> headers()
-
headers
Response headers(Map<? extends CharSequence,? extends CharSequence> value)
-
send
void send(io.vertx.core.http.HttpServerResponse response)
-
empty
static Response empty()
Creates an empty response.
-
empty
static Response empty(int statusCode)
Creates an empty response for a givenstatusCode.
-
wrap
static Response wrap(io.vertx.core.buffer.Buffer serialized)
Wraps a Buffer into a response.
-
of
static <T> Response of(T payload)
Wraps an object as a response.
-
ofNullable
static <T> Response ofNullable(T payload)
Wraps a nullable object as a response.
-
send
static void send(io.vertx.ext.web.RoutingContext context, Object payload)Sends a response to the client. Internally it serializes thepayloadobject using a previously definedPayloadSerializationStrategy. This method though is a semantically-equivalent tosend(HttpServerResponse), but with different syntax.- Parameters:
context-payload-
-
send
static void send(io.vertx.ext.web.RoutingContext context, Response response)Sends a response to the client. It will ensure that the defined statusCode and headers are send to the client. It also usessend(HttpServerResponse)to perform the serialization, allowing developers to design custom and powerful serialization mechanisms.
-
sendError
static void sendError(io.vertx.ext.web.RoutingContext context, Throwable cause)Serializes aThrowableand sends as a response to the client. Internally it will use the appropriateExceptionHandlerto handle the failure and generate the response object.
-
sendDefaultNoContent
static void sendDefaultNoContent(io.vertx.ext.web.RoutingContext context)
Sends an empty response to the client.- See Also:
Kos.defaultStatusForEmptyResponses
-
-