Skip to main content

//clika-runtime/io.clika.runtime/ServerResponse/Companion

Companion

[common]
object Companion

Functions​

NameSummary
bytes[common]
fun bytes(body: ByteArray, contentType: String, status: Int = 200): ServerResponse
Raw bytes with an explicit content type.
error[common]
fun error(status: Int): ServerResponse
A status alone; its page comes from the server's error handler.
file[common]
fun file(path: String): ServerResponse
Serve a file, its type inferred from the extension (contain path before deriving it from request input).
html[common]
fun html(body: String, status: Int = 200): ServerResponse
A text/html response.
json[common]
fun json(body: String, status: Int = 200): ServerResponse
An application/json response.
redirect[common]
fun redirect(location: String, status: Int = 302): ServerResponse
A redirect to location (emitted verbatim: validate it before building it from request input).
sse[common]
fun sse(producer: EventProducer): ServerResponse
A Server-Sent-Events body pulled from producer, one event per pull, until it answers null.
stream[common]
fun stream(contentType: String, producer: ChunkProducer): ServerResponse
A chunked body pulled from producer on a server worker until it answers null; a producer that raises ends the stream (the headers are already out, so the runtime's log line is the only signal).
text[common]
fun text(body: String, status: Int = 200): ServerResponse
A text/plain response.