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)