Consider the following coarse grained REST apis for a Contact resource
POST /api/contacts
GET /api/contacts
GET /api/contacts/:id
PUT /api/contacts/:id
DELETE /api/contacts/:id
Consider using eventsourcing for the contact resource, i.e. commands are validated and events are stored. So every event must be stored, including each field level change.
CreateContactCommand -> | Contact("john", "doe", 25) | -> ContactCreatedEvent
FirstNameChangeCommand -> | Contact("jane", "doe", 25) | -> FirstNameChangedEvent
LastNameChangeCommand -> | Contact("jane", "dear", 25) | -> LastNameChangedEvent
AgeChangeCommand -> | Contact("jane", "doe", 30) | -> AgeChangedEvent
Now, combining REST and EventSourcing both.
Doing REST, how the client communicates to the above standard REST APIs for field level changes to generate commands at server side REST end point?
Major question is, how to design REST API so that it can also support the commands eventually supporting eventsourcing?
If anybody could shed light on this, the help would be greatly appreciated.