Created
September 25, 2018 04:46
-
-
Save Tea-Ayataka/2f4b971e6458f28b3d513305c7bfb5e4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun PipelineContext<*, ApplicationCall>.setSession(id: String, value: String) { | |
val session = call.sessions.get<Session>() ?: Session() | |
session.data[id] = value | |
call.sessions.set(session) | |
} | |
fun PipelineContext<*, ApplicationCall>.getSession(id: String): String? { | |
return call.sessions.get<Session>()?.data?.get(id) | |
} | |
fun PipelineContext<*, ApplicationCall>.clearSession(id: String): String? { | |
return call.sessions.get<Session>()?.data?.remove(id) | |
} | |
class Session(val data: HashMap<String, String> = hashMapOf()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment