Skip to main content

//clika-runtime/io.clika.runtime/ServerRequest

ServerRequest

[common]
class ServerRequest

A request as a handler sees it: a borrowed view, valid for the handler call alone; never keep it past the return. The observers are always present; the lookups answer null when the header, query field, cookie or form field is absent; the path captures of a pattern route are read by index or by name; setAttr / attr are the middleware-to-handler channel (read-only inside the failure and error pages and the logger).

Properties​

NameSummary
body[common]
val body: ByteArray
The raw request body.
clientIp[common]
val clientIp: String
The peer's socket address (not what a header claims).
method[common]
val method: Method
The HTTP verb.
paramCount[common]
val paramCount: Long
The number of path captures on the matched pattern route.
path[common]
val path: String
The decoded path, without the query string.
shouldStop[common]
val shouldStop: Boolean
True when the connection closed or the server is stopping.

Functions​

NameSummary
attr[common]
fun attr(name: String): String?
A request attribute set by setAttr, or null.
bodyText[common]
fun bodyText(): String
The body decoded as UTF-8 text.
cookie[common]
fun cookie(name: String): String?
A cookie's value from the Cookie header, or null.
formField[common]
fun formField(name: String): String?
A text field of a form body, or null.
formFile[common]
fun formFile(name: String): FormFile?
A file part of a multipart body, or null.
formParts[common]
fun formParts(): List<FormPart>
Every part of a multipart body, repeated names kept; empty for another body kind.
header[common]
fun header(name: String): String?
A header's value, matched without regard to case, or null.
param[common]
fun param(index: Long): String
A path capture by 0-based index; fails with NOT_FOUND when there is none.
[common]
fun param(name: String): String
A path capture by its (?P<name>...) group name; fails with NOT_FOUND when there is none.
query[common]
fun query(name: String): String?
A query field's first value, or null.
queryAll[common]
fun queryAll(name: String): List<String>
Every value of a query field.
setAttr[common]
fun setAttr(name: String, value: String)
Attach a per-request attribute, the middleware-to-handler channel.