This commit is contained in:
InsanusMokrassar 2020-08-15 12:46:59 +06:00
parent 626edccc7d
commit 8a4934a65a
3 changed files with 10 additions and 4 deletions

View File

@ -15,12 +15,12 @@ class ReadPublishingKeysRepoKtorClient (
private val client: HttpClient = HttpClient() private val client: HttpClient = HttpClient()
) : ReadPublishingKeysRepo { ) : ReadPublishingKeysRepo {
override suspend fun getPostIdByTriggerControlKey(key: TriggerControlKey): PostId? = client.uniget( override suspend fun getPostIdByTriggerControlKey(key: TriggerControlKey): PostId? = client.uniget(
"$baseUrl/$getPostIdByTriggerControlKeyRoute", "$baseUrl/$getPostIdByTriggerControlKeyRoute/$key",
PostId.serializer().nullable PostId.serializer().nullable
) )
override suspend fun getTriggerControlKeyByPostId(postId: PostId): TriggerControlKey? = client.uniget( override suspend fun getTriggerControlKeyByPostId(postId: PostId): TriggerControlKey? = client.uniget(
"$baseUrl/$getTriggerControlKeyByPostIdRoute", "$baseUrl/$getTriggerControlKeyByPostIdRoute/$postId",
TriggerControlKey.serializer().nullable TriggerControlKey.serializer().nullable
) )
} }

View File

@ -1,5 +1,7 @@
package com.insanusmokrassar.postssystem.publishing.ktor package com.insanusmokrassar.postssystem.publishing.ktor
const val publishingKeysRootRoute = "publishingKeys"
const val getPostIdByTriggerControlKeyRoute = "getPostIdByTriggerControlKey" const val getPostIdByTriggerControlKeyRoute = "getPostIdByTriggerControlKey"
const val getTriggerControlKeyByPostIdRoute = "getTriggerControlKeyByPostId" const val getTriggerControlKeyByPostIdRoute = "getTriggerControlKeyByPostId"

View File

@ -2,13 +2,17 @@ package com.insanusmokrassar.postssystem.publishing.ktor.server
import com.insanusmokrassar.postssystem.core.publishing.repos.PublishingKeysRepo import com.insanusmokrassar.postssystem.core.publishing.repos.PublishingKeysRepo
import com.insanusmokrassar.postssystem.ktor.server.configurators.ApplicationRoutingConfigurator import com.insanusmokrassar.postssystem.ktor.server.configurators.ApplicationRoutingConfigurator
import com.insanusmokrassar.postssystem.publishing.ktor.publishingKeysRootRoute
import io.ktor.routing.Route import io.ktor.routing.Route
import io.ktor.routing.route
fun Route.configurePublishingKeysRepoRoutes ( fun Route.configurePublishingKeysRepoRoutes (
proxyTo: PublishingKeysRepo proxyTo: PublishingKeysRepo
) { ) {
route(publishingKeysRootRoute) {
configureReadPublishingKeysRepoRoutes(proxyTo) configureReadPublishingKeysRepoRoutes(proxyTo)
configureWritePublishingKeysRepoRoutes(proxyTo) configureWritePublishingKeysRepoRoutes(proxyTo)
}
} }
class PublishingKeysRepoRoutingConfigurator ( class PublishingKeysRepoRoutingConfigurator (