We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
In the Kvision-Ktor framework, I can define a service manager and automate routing like so:
applyRoutes(AuthenticationServiceManager)
However, I would also like to use Ktor sessions and cookies for tracking users. With Ktor routing I can do the following:
data class SampleSession(val name: String, val value: Int) ... get("/get") { val session = call.sessions.get<SampleSession>() ?: SampleSession(0) call.respondHtml {"Counter: ${session.counter}"} }
What's the best way to achieve this using ktor but access the result as a function from Kvision?
The text was updated successfully, but these errors were encountered:
Use dependency injection and inject ApplicationCall instance into your Service class. Then you can use the same code as above. Here is the example of injection: https://github.com/rjaros/kvision-examples/blob/17acf84f31923ec2c40d3d75696fdfa6db941d0b/addressbook-fullstack-ktor/server/src/main/kotlin/com/example/Service.kt#L22
ApplicationCall
Sorry, something went wrong.
Closing this as problem solved 👍
No branches or pull requests
In the Kvision-Ktor framework, I can define a service manager and automate routing like so:
However, I would also like to use Ktor sessions and cookies for tracking users. With Ktor routing I can do the following:
What's the best way to achieve this using ktor but access the result as a function from Kvision?
The text was updated successfully, but these errors were encountered: