CQRS and REST HATEOAS mismatch

Suppose you have a Foo model. One business example is simply to create an instance of Foo, so my model has a corresponding CreateFooCommand called by calling a POST request for a given REST endpoint.

Of course, there are other teams.

But now I have a ViewModel that is derived from my DomainModel. It's just a sql table with raw data - every Foo instance from DomainModel has a corresponding derived instance of ViewModel. Both have different identifiers (on DomainModel there is DomainID, on ViewModel it is just a value long).

Now: should I even take care of HATEOAS in that case? In the correct REST implementation, I should at least return the url in the header. But since my view model is derived only from DomainModel, do I care? I don’t even have a view model ID at the time of creating my DomainModel.

+4
source share
2 answers

Because CQRS means that requests are separate from commands, you cannot immediately execute the request because the command may not yet be applied (it may never be).

To reconcile this with HATEOAS, instead of returning 200 OK from the POST request, the service can return 202 Accepted :

, . , , . , .

202 . - - (, - , ), , . , , , , .

( )

, , . / View , .

REST in Practice - Restbucks.

- - , . .

+10

, CQRS - , " ". , , . . , . , REST POST , . , , .

URI , , Mark - . CQRS , FE/BE FE BE. . , 99% , .

+1

All Articles