mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2025-11-15 11:30:25 +00:00
ReadKeyValuesRepo#removeWithValue
This commit is contained in:
@@ -47,6 +47,17 @@ class KtorWriteKeyValuesRepoClient<Key : Any, Value : Any>(
|
||||
}.throwOnUnsuccess { "Unable to remove $toRemove" }
|
||||
}
|
||||
|
||||
@OptIn(InternalAPI::class)
|
||||
override suspend fun removeWithValue(v: Value) {
|
||||
httpClient.post(
|
||||
buildStandardUrl(baseUrl, removeWithValueRoute)
|
||||
) {
|
||||
body = v
|
||||
bodyType = valueTypeInfo
|
||||
contentType(contentType)
|
||||
}.throwOnUnsuccess { "Unable to remove $v" }
|
||||
}
|
||||
|
||||
@OptIn(InternalAPI::class)
|
||||
override suspend fun clear(k: Key) {
|
||||
httpClient.post(
|
||||
|
||||
@@ -13,6 +13,7 @@ const val onDataClearedRoute = "onDataCleared"
|
||||
|
||||
const val addRoute = "add"
|
||||
const val removeRoute = "remove"
|
||||
const val removeWithValueRoute = "removeWithValue"
|
||||
const val clearRoute = "clear"
|
||||
const val clearWithValueRoute = "clearWithValue"
|
||||
const val setRoute = "set"
|
||||
|
||||
@@ -46,6 +46,11 @@ inline fun <reified Key : Any, reified Value : Any> Route.configureWriteKeyValue
|
||||
call.respond(HttpStatusCode.OK)
|
||||
}
|
||||
|
||||
post(removeWithValueRoute) {
|
||||
originalRepo.removeWithValue(call.receive())
|
||||
call.respond(HttpStatusCode.OK)
|
||||
}
|
||||
|
||||
post(clearRoute) {
|
||||
originalRepo.clear(call.receive())
|
||||
call.respond(HttpStatusCode.OK)
|
||||
|
||||
Reference in New Issue
Block a user