'Best practice of Read-Modify-Write Rest Api Design
I have a restful api to update the bunch of objects on the server side. For example, I have an object like this:
{
counter: int,
bit_mask: int,
other_value: string,
}
on the client side, I want to do some update based on the inner method on the server side, like:
{
counter++,
bit_mask.some_inner_method(some_value),
other_value = new_value
}
I want to expose an idempotent and atomic rest API for this kind of update instead of read it to the client-side and writing it back to the server side. Here is my naive thought on the body of this API
{
overwrite: {
other_value: "new_value",
},
updates: [
{
property: "counter",
operator: "inc"
},
{
property: "bit_mask",
operator: "some_inner_method",
params: ["some_value"]
}
]
}
I think this should be a common use case, but I didn't find any discussion about it online. Is there any better solution to this scenario?
Solution 1:[1]
There is something like an security-bot design. In this design a non-service-deamon who not accept any incoming connections and have no db but read/write to/from Microservices using a Regelwerk. Like an arbiter.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Grim |
