This commit is contained in:
2021-06-15 14:24:00 +06:00
parent eba41066b4
commit a411355b4f
11 changed files with 94 additions and 13 deletions

View File

@@ -67,6 +67,15 @@ class KtorWriteOneToManyKeyValueRepo<Key, Value> (
Unit.serializer(),
)
override suspend fun clearWithValue(v: Value) = unifiedRequester.unipost(
buildStandardUrl(
baseUrl,
clearWithValueRoute,
),
BodyPair(valueSerializer, v),
Unit.serializer(),
)
override suspend fun set(toSet: Map<Key, List<Value>>) = unifiedRequester.unipost(
buildStandardUrl(
baseUrl,
@@ -75,4 +84,4 @@ class KtorWriteOneToManyKeyValueRepo<Key, Value> (
BodyPair(keyValueMapSerializer, toSet),
Unit.serializer(),
)
}
}

View File

@@ -14,4 +14,5 @@ const val onDataClearedRoute = "onDataCleared"
const val addRoute = "add"
const val removeRoute = "remove"
const val clearRoute = "clear"
const val setRoute = "set"
const val clearWithValueRoute = "clearWithValue"
const val setRoute = "set"

View File

@@ -72,6 +72,17 @@ fun <Key, Value> Route.configureOneToManyWriteKeyValueRepoRoutes(
}
}
post(clearWithValueRoute) {
unifiedRouter.apply {
val v = uniload(valueSerializer)
unianswer(
Unit.serializer(),
originalRepo.clearWithValue(v),
)
}
}
post(setRoute) {
unifiedRouter.apply {
val obj = uniload(keyValueMapSerializer)