-
Notifications
You must be signed in to change notification settings - Fork 0
PATCH HTTP Messages
jayoungers edited this page Oct 18, 2018
·
2 revisions
Most REST APIs will make use of the HTTP Verbs of GET, POST, and PUT: their use cases are fairly standard, with the body of the message containing the corresponding URL's Entity.
The HTTP verb of PATCH is a different story: it is not often used, and when it is used, it is used in inconsistent ways.
For the PatchMap
library, it has been designed to handle messages that somewhat follow the JavaScript Object Notation (JSON) Patch specification. It is capable of parsing messages that look like so:
PATCH /api/entity-type/1 HTTP/1.1
Host: my-app.com
[
{ "op": "replace", "path": "/status", "value": "Closed" },
{ "op": "replace", "path": "status", "value": "Open" },
{ "op": "remove", "path": "tags/programming" },
{ "op": "replace", "path": "author", "value": { "Name": "John Doe" } }
]
The deviations from the specification are:
- The initial
/
in the path is optional (the first two operations refer to the same path) - For collections, opposed to using an index, it will assume the text after the path's slash is some sort of collection identifier, which you can define as you see fit. So for the 3rd operation above,
PatchMap
would see the operation having a path oftags
, with aCollectionKey
of"Programming"
Concepts
PatchMap Library
Examples