I have a rest service, not restfull. The module is stateless and just expose some rest endopoints: receives a request, transform it, invokes external endopints, and then compose a Json response.
The thing is that the response is quite verbose, and some of the fields are quite big.
I've been asked to provide a filtering at request level, so that the response contains only the requested data.
Just to provide an example: my exposed method is a POST, and accept an image encoded BASE64, and the response too, can contain an image, and many other fields:
request: { image="<here a long BASE64 encoded request>"}
response: {result="success",
message="it was a success",
responseImage="<another base64 encoded image>",
longArray1=[
{first="...", second="...", third="..."},
{first="...", second="...", third="..."},
....many!
],
longArray2=[
{first2="...", second2="...", third2="..."},
{first2="...", second2="...", third2="..."},
....many!
]
}
What I want is avoid to reinvent the wheel. Is there a known pattern to make a query (adding something in the queryString, or in the Json request, and how) so that the consumer can choose in advance what fields to receive in response, and save bandwidth in the response?
Aucun commentaire:
Enregistrer un commentaire