---
title: "Companion"
sidebar_label: "Companion"
description: "Kotlin binding reference: Companion."
---

<!-- Generated by tools/api_reference/generate_api_docs.py. Do not edit. -->

//[clika-runtime](../../../../index.md)/[io.clika.runtime](../../index.md)/[ServerResponse](../index.md)/[Companion](index.md)

# Companion

[common]\
object [Companion](index.md)

## Functions

| Name | Summary |
|---|---|
| [bytes](bytes.md) | [common]<br>fun [bytes](bytes.md)(body: [ByteArray](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html), contentType: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html), status: [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) = 200): [ServerResponse](../index.md)<br>Raw bytes with an explicit content type. |
| [error](error.md) | [common]<br>fun [error](error.md)(status: [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)): [ServerResponse](../index.md)<br>A status alone; its page comes from the server's error handler. |
| [file](file.md) | [common]<br>fun [file](file.md)(path: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)): [ServerResponse](../index.md)<br>Serve a file, its type inferred from the extension (contain [path](file.md) before deriving it from request input). |
| [html](html.md) | [common]<br>fun [html](html.md)(body: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html), status: [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) = 200): [ServerResponse](../index.md)<br>A `text/html` response. |
| [json](json.md) | [common]<br>fun [json](json.md)(body: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html), status: [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) = 200): [ServerResponse](../index.md)<br>An `application/json` response. |
| [redirect](redirect.md) | [common]<br>fun [redirect](redirect.md)(location: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html), status: [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) = 302): [ServerResponse](../index.md)<br>A redirect to [location](redirect.md) (emitted verbatim: validate it before building it from request input). |
| [sse](sse.md) | [common]<br>fun [sse](sse.md)(producer: [EventProducer](../../EventProducer/index.md)): [ServerResponse](../index.md)<br>A Server-Sent-Events body pulled from [producer](sse.md), one event per pull, until it answers null. |
| [stream](stream.md) | [common]<br>fun [stream](stream.md)(contentType: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html), producer: [ChunkProducer](../../ChunkProducer/index.md)): [ServerResponse](../index.md)<br>A chunked body pulled from [producer](stream.md) 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](text.md) | [common]<br>fun [text](text.md)(body: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html), status: [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) = 200): [ServerResponse](../index.md)<br>A `text/plain` response. |