Slide 21
Slide 21 text
Resource
class MyServer private constructor() {
fun routes(): Unit = println("Handling incoming requests")
suspend fun shutdown(exitCase: ExitCase) = withContext(Dispatchers.IO){
println("Shutting down server with $exitCase")
}
companion object {
fun create(): Resource =
Resource(
{ MyServer().also { println("Initialising server") } },
{ server, exitCase -> server.shutdown(exitCase) }
)
}
}