I'm developing an application that will persist view models for consumption by the UI. For a REST service, is it considered a good idea to re-use view models directly as resources, or should I create specific resource classes and use something like AutoMapper to map the view models onto resources?
Asked
Active
Viewed 234 times
1 Answers
1
I can't speak to the tune of openrasta, but in the context of REST you have resources and representations. The resource should be capable of handling the semantics of HTTP verbs and how they make sense in your domain model. Clients generally interact with representations of your resources (XML, HTML) and this leads people to think that a resource and a controller are the same thing. I disagree. MVC makes sense to me as a client oriented paradigm and while some argue that it is semantics, I just don't see how you have views and models in REST.
In short, I would create new resource classes that perhaps talk to or re-use large parts of, your controllers in order to accomplish what makes sense from the REST perspective.

Doug Moscrop
- 4,479
- 3
- 26
- 46