mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2025-09-04 23:59:29 +00:00
set method in realizations
This commit is contained in:
@@ -42,12 +42,12 @@ class KtorWriteOneToManyKeyValueRepo<Key, Value> (
|
||||
override suspend fun add(toAdd: Map<Key, List<Value>>) = client.unipost(
|
||||
buildStandardUrl(
|
||||
baseUrl,
|
||||
clearRoute,
|
||||
addRoute,
|
||||
),
|
||||
BodyPair(keyValueMapSerializer, toAdd),
|
||||
Unit.serializer(),
|
||||
)
|
||||
override suspend fun clear(k: Key) = client.unipost(
|
||||
override suspend fun clear(k: Key) = client.unipost(
|
||||
buildStandardUrl(
|
||||
baseUrl,
|
||||
clearRoute,
|
||||
@@ -55,4 +55,13 @@ class KtorWriteOneToManyKeyValueRepo<Key, Value> (
|
||||
BodyPair(keySerializer, k),
|
||||
Unit.serializer(),
|
||||
)
|
||||
|
||||
override suspend fun set(toSet: Map<Key, List<Value>>) = client.unipost(
|
||||
buildStandardUrl(
|
||||
baseUrl,
|
||||
setRoute,
|
||||
),
|
||||
BodyPair(keyValueMapSerializer, toSet),
|
||||
Unit.serializer(),
|
||||
)
|
||||
}
|
@@ -13,4 +13,5 @@ const val onDataClearedRoute = "onDataCleared"
|
||||
|
||||
const val addRoute = "add"
|
||||
const val removeRoute = "remove"
|
||||
const val clearRoute = "clear"
|
||||
const val clearRoute = "clear"
|
||||
const val setRoute = "set"
|
@@ -61,4 +61,13 @@ fun <Key, Value> Route.configureOneToManyWriteKeyValueRepoRoutes(
|
||||
originalRepo.clear(key),
|
||||
)
|
||||
}
|
||||
|
||||
post(setRoute) {
|
||||
val obj = call.uniload(keyValueMapSerializer)
|
||||
|
||||
call.unianswer(
|
||||
Unit.serializer(),
|
||||
originalRepo.set(obj)
|
||||
)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user