Skip to content

route

inline fun <In : Any, Out : Any, Failure : FailureSpec, Params : Parameters> Route.route(endpoint: Endpoint<In, Out, Failure, Params>, crossinline block: suspend TypedResponseScope<In, Out, Failure, Params>.() -> Unit)

Declares a Ktor handler matching a Spine endpoint.

Example

routing {
    route(Api.Users.logIn) {
        val (user, token) = authService.verifyLogIn(body.username, body.password)
        call.response.cookies.append("token", token)
        respond(user)
    }
}

For the full list of available methods, see TypedResponseScope.