When a client requests my .../resources/user
URL with a HTTP GET
I get the following response:
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<collection>
<User id="5">
<Password>DC647EB65E6711E155375218212B3964</Password>
<FirstName>Super</FirstName>
<LastName>Admin</LastName>
<Role id="4">
<Description>Default Guest Role</Description>
<Group id="2">
<Description>Default Guest Group</Description>
<Name>GuestGroup</Name>
</Group>
<Name>Guest</Name>
</Role>
<Role id="3">
<Description>Default Super Admin Role</Description>
<Group id="1">
<Description>Default Admin Group</Description>
<Name>AdminGroup</Name>
</Group>
<Name>SuperAdmin</Name>
</Role>
<Username>superadmin</Username>
</User>
<User id="6">
<Password>DC647EB65E6711E155375218212B3964</Password>
<FirstName/>
<LastName>Guest</LastName>
<Role id="4">
<Description>Default Guest Role</Description>
<Group id="2">
<Description>Default Guest Group</Description>
<Name>GuestGroup</Name>
</Group>
<Name>Guest</Name>
</Role>
<Username>guest</Username>
</User>
</collection>
For data transport efficiency purposes I would also like the client to be able to request a short version of this response. Something like:
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<collection>
<User id="5">
<Password>DC647EB65E6711E155375218212B3964</Password>
<FirstName>Super</FirstName>
<LastName>Admin</LastName>
<Role id="4" />
<Role id="3" />
<Username>superadmin</Username>
</User>
<User id="6">
<Password>DC647EB65E6711E155375218212B3964</Password>
<FirstName/>
<LastName>Guest</LastName>
<Role id="4" />
<Username>guest</Username>
</User>
</collection>
What is the best way to identify a full and a short request from the client and why? Client technology should be agnostic. Server technology is Java EE 7
A few options I thought of myself:
- Sub level webservices like
.../resources/user/short
- Different webservices like
.../resources/user2
- Use a custom HTTP parameter lik
Accept-Length : Short
- Use the HTTP request field
Expect : Short
9
My view is that the client is requesting a different representation of the resource i.e. a short one.
When you request a different representation (like json or xml) this normally gets tagged at the end of the resource e.g. /some/resource.json, /some/resource.xml
So you could take the same logic and do something like /some/resource.short.json
1