Response

Data to send back to the client after it makes a request to an API endpoint.

An empty successful response is automatically created and passed into an API via an ApiContext. Developers implementing an API endpoint should modify this response with code like the following:

@Api
fun demo(ctx: ApiContext) {
ctx.res.setBodyText("This is how you send text back to the client")
}

See also

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard

The body payload to send back

Link copied to clipboard

The content type of the body, e.g. "image/jpeg" or "application/json". Can include parameters.

Link copied to clipboard

Any additional headers to send back to the client.

Link copied to clipboard
var status: Int

Functions

Link copied to clipboard
fun Response.setAsRedirect(newPath: String, status: Int = 307, isApiPath: Boolean = false)

Set this to a response that tells the client that the requested resource has moved to a new location.

Link copied to clipboard

Convenience method for setting the body to a text value.