Cleaner code
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
package be.vandewalleh.extensions
|
||||
|
||||
import be.vandewalleh.auth.UserDbIdPrincipal
|
||||
import be.vandewalleh.auth.UserIdPrincipal
|
||||
import io.ktor.application.*
|
||||
import io.ktor.auth.*
|
||||
import io.ktor.http.*
|
||||
@@ -17,4 +17,4 @@ suspend fun ApplicationCall.respondStatus(status: HttpStatusCode) {
|
||||
/**
|
||||
* @return the userId for the currently authenticated user
|
||||
*/
|
||||
fun ApplicationCall.authenticatedUserId() = principal<UserDbIdPrincipal>()!!.id
|
||||
fun ApplicationCall.authenticatedUserId() = principal<UserIdPrincipal>()!!.id
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
package be.vandewalleh.extensions
|
||||
|
||||
import kotlinx.coroutines.*
|
||||
|
||||
|
||||
fun <T> ioAsync(block: suspend CoroutineScope.() -> T): Deferred<T> {
|
||||
return CoroutineScope(Dispatchers.IO).async(block = block)
|
||||
}
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
suspend inline fun <T> launchIo(crossinline block: () -> T): T =
|
||||
withContext(Dispatchers.IO) {
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
package be.vandewalleh.extensions
|
||||
|
||||
import io.ktor.application.*
|
||||
import io.ktor.routing.*
|
||||
|
||||
abstract class RoutingBuilder(val builder: Routing.() -> Unit)
|
||||
|
||||
abstract class ApplicationBuilder(val builder: Application.() -> Unit)
|
||||
Reference in New Issue
Block a user