Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How would you implement a partial request & response, like the youtube api, using ServiceStack?

Tags:

servicestack

In the Youtube API, there is the power to request a "partial feed".

This allows the app developer to tailor the size and sturcture of the data returned, by specifying which "fields" to return.

i.e. GET api/person/1?fields=(id,email) would return a DTO containing only the id and the email fields, not the whole person response.

How would you attempt this using ServiceStack? Is there some way to attach a callback to the serialiser to control which properties to include in the response object?

like image 970
jmc Avatar asked Nov 04 '22 05:11

jmc


1 Answers

From my experience servicestack only returns fields that actually has data. If my experience is correct then all you would need to do is figure out the best way to architect the request so that it is asking for specific data to return, this way you would only populate the response with data requested thus servicestack would only return that.

like image 83
Michael Josiah Avatar answered Nov 08 '22 03:11

Michael Josiah