by graypegg · 2y ago · 0 comments
HTTP/1.1 PATCH /user
Content-Type: application/json-patch+json
[
{
"op": "replace",
"path": "/username",
"value": "bob"
}
]
why not HTTP/1.1 PATCH /user/username
Content-Type: application/json
"bob"
I feel like you could pretty sensibly implement replace/delete/append with that.Edit: "test" and "copy" from the json patch spec are unique! So there is those, as well as doing multiple edits all at once in a sort of "transaction".
But I just find that the 1 by 1 approach is easier to reason about if you're opening this up to the internet. I'd personally feel more comfortable with the security model of 1 URL + Session => 1 JSON key.
You want them to all fail or not,
One-by-one is a bit of a weird suggestion tbh. You shouldn't be reasoning that way about code.
If you are going to get a 4xx response to one of the 4 property updates you want them all to fail at once.
Just like anything else we use like SQL.