Book description
While the REST design philosophy has captured the imagination of web and enterprise developers alike, using this approach to develop real web services is no picnic. This cookbook includes more than 100 recipes to help you take advantage of REST, HTTP, and the infrastructure of the Web. You'll learn ways to design RESTful web services for client and server applications that meet performance, scalability, reliability, and security goals, no matter what programming language and development framework you use.
Each recipe includes one or two problem statements, with easy-to-follow, step-by-step instructions for solving them, as well as examples using HTTP requests and responses, and XML, JSON, and Atom snippets. You'll also get implementation guidelines, and a discussion of the pros, cons, and trade-offs that come with each solution.
- Learn how to design resources to meet various application scenarios
- Successfully design representations and URIs
- Implement the hypertext constraint using links and link headers
- Understand when and how to use Atom and AtomPub
- Know what and what not to do to support caching
- Learn how to implement concurrency control
- Deal with advanced use cases involving copying, merging, transactions, batch processing, and partial updates
- Secure web services and support OAuth
Publisher resources
Table of contents
- Preface
-
1. Using the Uniform Interface
- 1.1. How to Keep Interactions Visible
- 1.2. When to Trade Visibility
- 1.3. How to Maintain Application State
- 1.4. How to Implement Safe and Idempotent Methods on the Server
- 1.5. How to Treat Safe and Idempotent Methods in Clients
- 1.6. When to Use GET
- 1.7. When to Use POST
- 1.8. How to Create Resources Using POST
- 1.9. When to Use PUT to Create New Resources
- 1.10. How to Use POST for Asynchronous Tasks
- 1.11. How to Use DELETE for Asynchronous Deletion
- 1.12. When to Use Custom HTTP Methods
- 1.13. When and How to Use Custom HTTP Headers
- 2. Identifying Resources
-
3. Designing Representations
- 3.1. How to Use Entity Headers to Annotate Representations
- 3.2. How to Interpret Entity Headers
- 3.3. How to Avoid Character Encoding Mismatch
- 3.4. How to Choose a Representation Format and a Media Type
- 3.5. How to Design XML Representations
- 3.6. How to Design JSON Representations
- 3.7. How to Design Representations of Collections
- 3.8. How to Keep Collections Homogeneous
- 3.9. How to Use Portable Data Formats in Representations
- 3.10. When to Use Entity Identifiers
- 3.11. How to Encode Binary Data in Representations
- 3.12. When and How to Serve HTML Representations
- 3.13. How to Return Errors
- 3.14. How to Treat Errors in Clients
- 4. Designing URIs
-
5. Web Linking
- 5.1. How to Use Links in XML Representations
- 5.2. How to Use Links in JSON Representations
- 5.3. When and How to Use Link Headers
- 5.4. How to Assign Link Relation Types
- 5.5. How to Use Links to Manage Application Flow
- 5.6. How to Deal with Ephemeral URIs
- 5.7. When and How to Use URI Templates
- 5.8. How to Use Links in Clients
- 6. Atom and AtomPub
-
7. Content Negotiation
- 7.1. How to Indicate Client Preferences
- 7.2. How to Implement Media Type Negotiation
- 7.3. How to Implement Language Negotiation
- 7.4. How to Implement Character Encoding Negotiation
- 7.5. How to Support Compression
- 7.6. When and How to Send the Vary Header
- 7.7. How to Handle Negotiation Failures
- 7.8. How to Use Agent-Driven Content Negotiation
- 7.9. When to Support Server-Driven Negotiation
- 8. Queries
- 9. Web Caching
-
10. Conditional Requests
- 10.1. How to Generate Last-Modified and ETag Headers
- 10.2. How to Implement Conditional GET Requests in Servers
- 10.3. How to Submit Conditional GET and HEAD Requests from Clients
- 10.4. How to Implement Conditional PUT Requests in Servers
- 10.5. How to Implement Conditional DELETE Requests in Servers
- 10.6. How to Make Unconditional GET Requests from Clients
- 10.7. How to Submit Conditional PUT and DELETE Requests from Clients
- 10.8. How to Make POST Requests Conditional
- 10.9. How to Generate One-Time URIs
-
11. Miscellaneous Writes
- 11.1. How to Copy a Resource
- 11.2. How to Merge Resources
- 11.3. How to Move a Resource
- 11.4. When to Use WebDAV Methods
- 11.5. How to Support Operations Across Servers
- 11.6. How to Take Snapshots of Resources
- 11.7. How to Undo Resource Updates
- 11.8. How to Refine Resources for Partial Updates
- 11.9. How to Use the PATCH Method
- 11.10. How to Process Similar Resources in Bulk
- 11.11. How to Trigger Bulk Operations
- 11.12. When to Tunnel Multiple Requests Using POST
- 11.13. How to Support Batch Requests
- 11.14. How to Support Transactions
-
12. Security
- 12.1. How to Use Basic Authentication to Authenticate Clients
- 12.2. How to Use Digest Authentication to Authenticate Clients
- 12.3. How to Use Three-Legged OAuth
- 12.4. How to Use Two-Legged OAuth
- 12.5. How to Deal with Sensitive Information in URIs
- 12.6. How to Maintain the Confidentiality and Integrity of Representations
- 13. Extensibility and Versioning
- 14. Enabling Discovery
- A. Additional Reading
- B. Overview of REST
- C. HTTP Methods
- D. Atom Syndication Format
- E. Link Relation Registry
- Index
- About the Author
- Colophon
- Copyright
Product information
- Title: RESTful Web Services Cookbook
- Author(s):
- Release date: March 2010
- Publisher(s): O'Reilly Media, Inc.
- ISBN: 9780596801687
You might also like
book
RESTful Web Services
"Every developer working with the Web needs to read this book."-- David Heinemeier Hansson, creator of …
book
RESTful Web API Patterns and Practices Cookbook
Many organizations today orchestrate and maintain apps that rely on other people's services. Software designers, developers, …
book
RESTful Web APIs
The popularity of REST in recent years has led to tremendous growth in almost-RESTful APIs that …
book
Service Design Patterns: Fundamental Design Solutions for SOAP/WSDL and RESTful Web Services
Web services have been used for many years. In this time, developers and architects have encountered …