Package kos.api
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(KosContext kosContext, io.vertx.core.http.HttpServerResponse response)static voidsend(KosContext kosContext, io.vertx.core.http.HttpServerResponse httpResponse, Object payload)Sends a response to the client.static voidsend(KosContext kosContext, io.vertx.ext.web.RoutingContext context, Object payload)Sends a response to the client.static voidsend(KosContext kosContext, io.vertx.ext.web.RoutingContext context, Response response)Sends a response to the client.static voidsendDefaultNoContent(KosContext kosContext, io.vertx.ext.web.RoutingContext context)Sends an empty response to the client.static voidsendError(KosContext kosContext, io.vertx.core.http.HttpServerRequest request, Throwable cause)Serializes aThrowableand sends as a response to the client.static voidsendError(KosContext kosContext, 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(KosContext kosContext, 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(KosContext kosContext, io.vertx.ext.web.RoutingContext context, Object payload)
Sends a response to the client. Internally it serializes thepayloadobject using a previously definedPayloadSerializationStrategy. Although this method is a semantically-equivalent tosend(KosContext,HttpServerResponse)it was designed to be called directly by the generated routes.
-
send
static void send(KosContext kosContext, io.vertx.core.http.HttpServerResponse httpResponse, Object payload)
Sends a response to the client. Internally it serializes thepayloadobject using a previously definedPayloadSerializationStrategy. Although this method is a semantically-equivalent tosend(KosContext,HttpServerResponse)it was designed to be called directly by the generated routes.
-
send
static void send(KosContext kosContext, io.vertx.ext.web.RoutingContext context, Response response)
Sends a response to the client. It will delegate tosend(KosContext, HttpServerResponse)to perform the serialization, allowing developers to design custom and powerful serialization mechanisms.
-
sendError
static void sendError(KosContext kosContext, 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.
-
sendError
static void sendError(KosContext kosContext, io.vertx.core.http.HttpServerRequest request, 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(KosContext kosContext, io.vertx.ext.web.RoutingContext context)
Sends an empty response to the client.- See Also:
KosContext.getExceptionHandler()
-
-