Link Search Menu Expand Document

Halting a request flow

If you want to suspend the execution of a request you can use halt(response). You can specify it in a before hook, in a route action or in an after hook.

import topinambur.http

fun `halt request`() {
        .before { _, res -> halt(res, UNAUTHORIZED_401, "Go away") }
        .get("/") { _, res -> res.status(OK_200) }
        .start().use {
            val response = "http://localhost:4545/".http.get()
            assertThat(response.body).isEqualTo("Go away")

An Open Source Project