Request

interface Request(source)

Information passed into an API endpoint from the client.

The request information will be passed in via an ApiContext. Developers implementing an API endpoint can read request values with code like the following:

@Api
suspend fun echo(ctx: ApiContext) {
val msg = ctx.req.params["msg"]
if (msg != null) {
ctx.res.body = Body.text("Received message: $msg")
}
else {
ctx.res.status = 400
ctx.res.body = Body.text("Missing: required parameter 'msg'")
}
}

See also

Inheritors

Types

Link copied to clipboard

Top-level container class for views about a connection for some request.

Properties

Link copied to clipboard
abstract val body: Body?

The body payload sent with the request.

Link copied to clipboard

Information about the connection that carried the request.

Link copied to clipboard
abstract val cookies: Map<String, String>

Any cookies sent with the request.

Link copied to clipboard
abstract val data: Data

A holder of user data that can be added to this request.

Link copied to clipboard
abstract val headers: Map<String, List<String>>

All headers sent with the request.

Link copied to clipboard
abstract val method: HttpMethod

The type of http method this call was sent with.

Link copied to clipboard
abstract val params: Map<String, String>

A list of key/value pairs extracted either from the user's query string or from any dynamic path parts.

Link copied to clipboard
abstract val queryParams: Map<String, String>

Like params but only for the query string.

Functions

Link copied to clipboard
suspend fun Request.readBodyText(): String?