Skip to content

routeWithRaise

Declares a Ktor handler matching a Spine endpoint.

The handler has the ability to Raise, including using any method from the Arrow DSL.

Example

routing {
    route(Api.Users.logIn) {
        ensure(body.password.size > 12) { PasswordTooShort }

        val (user, token) = withError({ IncorrectCredentials }) {
            call.response.cookies.append("token", token)
        }

        respond(user)
    }
}

For the full list of available methods, see TypedResponseScope.