Package kos.api
Interface Response
- All Known Implementing Classes:
AbstractResponse,EmptyResponse,RawResponse,SerializableResponse
public interface Response
Represents a (mutable object) response to be sent to the http client.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Responsestatic final Responsestatic final Responsestatic final Responsestatic final Responsestatic final Responsestatic final Responsestatic final Responsestatic final Responsestatic final Responsestatic final Responsestatic final Responsestatic final Responsestatic final Responsestatic final Responsestatic final Response -
Method Summary
Modifier and TypeMethodDescriptionaddHeader(CharSequence key, CharSequence value) static Responseempty()Creates an empty response (defaults to 204 HTTP Status).static Responseempty(int statusCode) Creates an empty response for a givenstatusCode.headers()headers(Map<CharSequence, CharSequence> value) static <T> Responseof(T payload) Wraps an object as a response (defaults to 200 HTTP Status).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(int value) static Responsewrap(io.vertx.core.buffer.Buffer serialized) Wraps a Buffer into a response (defaults to 200 HTTP Status).
-
Field Details
-
CREATED
-
ACCEPTED
-
NO_CONTENT
-
BAD_REQUEST
-
UNAUTHORIZED
-
FORBIDDEN
-
NOT_FOUND
-
METHOD_NOT_ALLOWED
-
NOT_ACCEPTABLE
-
CONFLICT
-
GONE
-
TOO_MANY_REQUESTS
-
NOT_IMPLEMENTED
-
BAD_GATEWAY
-
SERVICE_UNAVAILABLE
-
GATEWAY_TIMEOUT
-
-
Method Details
-
statusCode
int statusCode() -
statusCode
-
headers
Map<CharSequence,CharSequence> headers() -
addHeader
-
headers
-
send
-
empty
Creates an empty response (defaults to 204 HTTP Status). -
empty
Creates an empty response for a givenstatusCode. -
wrap
Wraps a Buffer into a response (defaults to 200 HTTP Status). -
of
Wraps an object as a response (defaults to 200 HTTP Status). -
ofNullable
Wraps a nullable object as a response. Null payloads results in 204 HTTP Status, resulting in 200 otherwise. -
send
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
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
Sends an empty response to the client.- See Also:
-