dany giguere
02/27/2022, 3:51 PMhasSignedUrlMiddleware
:
get("/demo/signed-url") {
hasSignedUrlMiddleware(context as ApplicationCall)
call.respondText("This is a text response from /demo/signed-url")
}
fun Application.hasSignedUrlMiddleware(context: ApplicationCall) {
routing {
val signature = context.request.queryParameters["signature"]
if(signature != "1234") {
throw AuthorizationException("Sorry you are not authorized")
}
}
}
I tried injecting it but it doesn’t work :
interface CtxService {
fun getCtx(): ApplicationCall
}
class CtxServiceImpl(val context: ApplicationCall) : CtxService {
override fun getCtx() = context
}
val ctxAppModule = module {
single<CtxService> { CtxServiceImpl(get()) }
}
I get this error: 500: org.koin.core.error.InstanceCreationException: Could not create instance for [Singleton:'app.plugins.CtxService']