Book Image

RESTful Java Web Services, Second Edition

Book Image

RESTful Java Web Services, Second Edition

Overview of this book

Table of Contents (17 chapters)
RESTful Java Web Services Second Edition
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

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...