Robert Kempton
05/10/2022, 2:18 AMmartmists
05/10/2022, 2:31 AMRobert Kempton
05/10/2022, 3:57 AMAleksei Tirman [JB]
05/10/2022, 8:20 AMRobert Kempton
05/10/2022, 5:03 PMsuspend fun requireHttps(
call: ApplicationCall,
handle: suspend (ApplicationCall) -> Unit
) = if (call.request.local.scheme != "https") {
call.response.status(HttpStatusCode.NotFound)
call.respond("")
} else {
handle(call)
}
In the route
post("/secure"){
requireHttps(call){
call.respond(service.doSecretStuff(call.receive()))
}
}
Thanks again for the suggestion, it turned out nice.