From 5cd4f00b1d42e18161220b659f986afd72361459 Mon Sep 17 00:00:00 2001 From: sergeych Date: Fri, 9 Dec 2022 02:44:06 +0100 Subject: [PATCH] some docs --- .../superlogin/server/SuperloginServer.kt | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/jvmMain/kotlin/net/sergeych/superlogin/server/SuperloginServer.kt b/src/jvmMain/kotlin/net/sergeych/superlogin/server/SuperloginServer.kt index b8be6e0..819c73e 100644 --- a/src/jvmMain/kotlin/net/sergeych/superlogin/server/SuperloginServer.kt +++ b/src/jvmMain/kotlin/net/sergeych/superlogin/server/SuperloginServer.kt @@ -10,8 +10,29 @@ import kotlin.random.Random fun randomACOLike(): ByteArray { return Random.nextBytes(117) } + +/** + * Create a superlogin server on a curretn adapter builder, using some session builder lambda. + * Note that session must inherit [SLServerSession] and implement necessary abstract methods + * that do store and retrieve user data. It sould be used like: + * ``` + * parsec3TransportServer(TestApiServer()) { + * // the session extends SLServerSession and contain app-specific data and + * // storage/retrieve methods: + * superloginServer { TestSession() } + * + * // Sample service-specifiv api (above login api): + * on(api.loginName) { + * println("login name called. now we have $currentLoginName : $superloginData") + * currentLoginName + * } + * } + * ``` + * + * @param sessionBuilder code that builds a new session over the adapter. + */ inline fun , H : CommandHost> AdapterBuilder.superloginServer( - crossinline sessionBuilder: suspend ()->T + crossinline sessionBuilder: suspend AdapterBuilder.()->T ) { newSession { sessionBuilder() } addErrors(SuperloginExceptionsRegistry)