Building a RESTful Web Service with Spring
图书信息
| 作者 | Ludovic Dewailly |
| 出版社 | Packt Publishing |
| ISBN | 9781785283192 |
| 出版时间 | 2015-10-14 |
| 字数 | 52.1万 |
| 分类 | 进口书,外文原版书,电脑,网络 |
读书简介
A hands-on guide to building an enterprise-grade, scalable RESTful web service using the Spring FrameworkAbout This BookFollow best practices and explore techniques such as clustering and caching to achieve a scalable web serviceLeverage the Spring Framework to quickly implement RESTful endpointsLearn to implement a client library for a RESTful web service using the Spring Framework Who This Book Is For This book is intended for those who want to learn to build RESTful web services with the Spring Framework. To make best use of the code samples included in the book, you should have a basic knowledge of the Java language. Previous experience with the Spring Framework would also help you get up and running quickly.What You Will LearnDeep dive into the principles behind RESTExpose CRUD operations through RESTful endpoints with the Spring FrameworkDevise response formats and error handling strategies, offering a consistent and flexible structure to simplify integration for service consumersFollow the best approaches for dealing with a service’s evolution while maintaining backward compatibilityUnderstand techniques to secure web servicesComply with the best ways to test RESTful web services, including tips for load testingOptimise and scale web services using techniques such as caching and clustering In Detail REST is an architectural style that tackles the challenges of building scalable web services. In today’s connected world, APIs have taken a central role on the web. APIs provide the fabric through which systems interact, and REST has become synonymous with APIs. The depth, breadth, and ease of use of Spring makes it one of the most attractive frameworks in the Java ecosystem. Marrying the two technologies is therefore a very natural choice. This book takes you through the design of RESTful web services and leverages the Spring Framework to implement these services. Starting from the basics of the philosophy behind REST, you’ll go through the steps of designing and implementing an enterprise-grade RESTful web service. Taking a practical approach, each chapter provides code samples that you can apply to your own circumstances. This book goes beyond the use of Spring and explores approaches to tackle resilience, security, and scalability concerns. You’ll learn techniques to deal with security in Spring and discover how to implement unit and integration test strategies. Finally, the book ends by walking you through building a Java client for your RESTful web service, along with some scaling techniques for it.Style and approach This book is a step-by-step, hands-on guide to designing and building RESTful web services. The book follows the natural cycle of developing these services and includes multiple code samples to help you.
目录
Building a RESTful Web Service with Spring
Table of Contents
Building a RESTful Web Service with Spring
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. A Few Basics
REST principles
Uniform interface
Client-Server
Stateless
Cacheable
Layered system
Code on demand
The Spring Framework and REST
Our RESTful web service
Architecture
Data model
Summary
2. Building RESTful Web Services with Maven and Gradle
Apache Maven
Dependency management in Apache Maven
Gradle
Dependency management in Gradle
The structure of our sample web service
The anatomy of a Service Module
Local versus Remote Service Invocations
Developing RESTful web services
Working with your favorite IDE
Making services executable
Starting services with Maven
Summary
3. The First Endpoint
The Inventory service
REST and the MVC pattern
Request mapping
Path mapping
HTTP method mapping
Request parameter mapping
Running the service
A few words on data representation
Summary
4. Data Representation
The Data-Transfer-Object design pattern
The API response format
The envelope format
Error management
Pagination support
Customizing JSON responses
API evolutions
HATEOAS
Versioning strategies
URI versioning
Representation versioning
Other approaches
Summary
5. CRUD Operations in REST
Mapping CRUD operations to HTTP methods
Creating resources
Quickly testing endpoints
JSON versus form data
Updating resources
The update endpoint
Testing update requests
Deleting resources
Overriding the HTTP method
Summary
6. Performance
HTTP compression
Content negotiation
gzip or deflate?
gzip compression in RESTful web services
Spring Boot
HTTP caching
Cache-Control
Private/Public caching
No caching
ETags
Last-Modified/If-Modified-Since headers
Room availability
An overview of implementation
The REST resource
Adding HTTP caching
Caching with ETags
Summary
7. Dealing with Security
The booking service
The REST resource
Authentication
HTTP Basic authentication
Using Basic authentication with Spring
HTTP Digest authentication
Token-based authentication
Other authentication methods
Authorization
Authorization with Spring
URL mapping
Resource annotations
Input validation
Java Bean annotations
Regular expressions
Validating bookings
Encryption
Storing sensitive data
Summary
8. Testing RESTful Web Services
Unit testing Spring controllers
Mocking
Simple mocking
Implementation stubbing with a mocking library
Mockito and Spring
Testing security
Integration testing
Continuous delivery
Integration tests with Spring Boot
Postman
Postman and security
Other forms of testing
User Acceptance Testing
Load testing
Summary
9. Building a REST Client
The basic setup
Declaring a client
Remote versus local clients
Availability and booking services
Handling security
The Basic authentication
The Digest authentication
HTTP public key pinning
Exception handling
Summary
10. Scaling a RESTful Web Service
Clustering
Scaling up versus scaling out
The benefits of clustered systems
Load balancing
Linear scalability
Distributed caching
Data-tier caching
First-level caching
Second-level caching
Application-tier caching
Asynchronous communication
Summary
Index
- 经济数学-微积分习题解答(安徽财经大学大学数学教学研究中心)
- 151 Provérbios de Shakespeare(Willian Castro)
- 分开以后我变成了你喜欢的样子(Josie乔)
- 软装设计师手册(简明敏)
- 侯大利刑侦笔记8:旧案寻踪(集侦查学、痕迹学、社会学、尸体解剖学、犯罪心理学的教科书式破案小说)(读客知识小说文库)(小桥老树)
- 女性排毒与食补(元秀 编著)
- 图说天下学生版 超级兵器传奇 世界王牌武器陆海空大阅兵(套装共3册)(试读本)(薛金冉 编著)
- Gone With the Windsors(Laurie Graham)
