RESTful resources and orthogonal resource concerns
If I'm using a 3-tier app with a RESTful resource orientated service in the middle tier accessed via HTTP, what is the best way to provide orthogonal resources to the UI tier?
An example of this would be a 'User' resource which has a field/property for a Country, now in the UI tier when editing the User I want to be able to pick from a drop down and th开发者_Go百科en update the resource via a PUT operation.
The question is how does the Country list get to the UI for editting the User? - do I make 2 seperate requests to the service, one for the Country resources and one for the User resource or do I combine these into 1 request.
Do two requests. This allows each representation to have difference caching rules. Caching the country list is probably a good idea.
When I do this, my XML representation looks like:
<User>
<Name>Bob Brown</Name>
<Country DomainUrl="/Setup/Country/PickList">
<Code>US</Code>
<Description>United States</Description>
</Country>
</User>
I also defer the loading of the Country list until the user actually clicks on the drop down.
精彩评论