Implementing partial response

Partial response refers to an optimization technique offered by the RESTful web APIs to return only the information (fields) required by the client. In this mechanism, the client sends the required field names as the query parameters for an API to the server, and the server trims down the default response content by removing the fields that are not required by the client. In the following example, the select query parameter is used for selecting fields that would be transferred over the wire:

/employees/1234?select=firstName,lastName,email 

The Jersey framework supports the partial response feature via org.glassfish.jersey.message.filtering.SelectableEntityFilteringFeature. To enable this feature, you just need to register SelectableEntityFilteringFeature in the application. The client can use the select query parameter to select the fields that would be transferred over the wire, as illustrated in the following example:

GET employees/1234?select=email,department.departmentName HTTP/1.1 

To learn more about this feature, see the Jersey example available at https://github.com/jersey/jersey/tree/2.18/examples/entity-filtering-selectable.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.59.227.82