In this video, we will take a look at the REST architecture, design principles, and constraints. We are going to discuss how REST's emphasis on scalability, generality of interfaces, independent deployment, and presence of intermediary components addresses the challenges of building modern distributed systems.
- [Andriy] Hi, and welcome to section one. This section is going to be the starting point of our journey into the world of RESTful web services. In this section, we will grasp the basics of what REST architecture style means in the context of HTTP web services. Once we answer this question, we're going to make an overview of the state of the art technologies of RESTful web services development on the JVM platform. And welcome to the second video of this section, and get a brief idea of what REST architecture is all about.
It should be enough to build a solid understanding of the foundations that RESTful web services are based on. In this video, we'll touch on what REST actually is and move on to get an overview of how it came into existence. We will then move on to view the essential REST principles and spend some time focusing on REST value proposition and its constraints along with discussing when to use REST. REST, or representational state transfer, is a style, a different way of thinking about architecture and designing web applications, services, and APIs.
For our industry, REST could be considered an old thing as its roots are dated back to 2000. From the beginning, REST was designed to be independent from the underlying protocol. But nowadays, thanks to tremendous popularity of the internet and World Wide Web, it is most widely used in the context of HTTP web services and APIs, heavily relying on semantics of this communication protocol. The REST style has many appealing properties and principles that address the challenges which modern web applications and services are facing today.
Among many, there are a few worth distinguishing. The uniform interface simplifies data manipulation. A client/server model separates clients from servers. Being stateless assumes no client context is stored on the server between requests. Although, in reality, servers may need to access some state associated with the client, also known as session state. Caching helps to eliminate unnecessary roundtrips between client and server.
Layered system design is the enabler for altering client server communication without changing any of them. We will now take a look at each of these principles in detail and discuss the importance and benefits of every principle in the context of HTTP-based distributed system communications spread across processes and physical machine boundaries. Uniform Interface Individual resources are identified using URIs or as we get used to it in the context of the Web, URLs, which are a subset of URIs.
They are sent to clients using different representations, notably JSON and XML. The client can manipulate the resources through the representations and submit them back to the server using appropriate HTTP verbs like POST, PUT, GET, DELETE, PATCH, HEAD, and OPTIONS. Client/Server Separation The clients and servers are naturally separated from each other, giving each part the freedom to evolve independently.
Stateless The server does not store any client context between the requests. Each request from any client contains all the information necessary to serve the request using headers, query, and powerful parameters or body. The session state is always held on the client. Cacheable Responses from servers could be cached by clients, although responses must describe themselves as cacheable or not. Caching, when done right, may significantly improve scalability and performance as the next time the client needs to execute the same request, the communication with the server could be completely avoided.
Note, it is faster for the client perspective. It also removes unnecessary load from servers. Layered Clients cannot tell for sure whether they are connected to the server directly or through an intermediary. This gives us the opportunity to improve overall system scalability and safety by introducing load balances, API gateways, shared caches, and security policy enforcements.
There is often confusion around REST web services and RESTful web services. However, it is very easy to draw a line between them. RESTful web services conform to all the required principles and constraints of the REST architecture while REST web services follows some but not all. Taking into account REST principles we have seen before, it becomes apparent that they are quite simple but powerful. Simplicity is one of the core values of REST, but simplicity does not come alone and brings the agility with itself.
RESTful web services encourage rapid development cycles and require much less time to production. Not only that, because of those loose coupling between servers and clients, RESTful web services can evolve very fast as well. It's very important in the era of modern highly competitive markets. In this video, we have been introduced to REST architecture style and the concepts of RESTful web services. In a nutshell, REST architecture was a breakthrough in the area of web services and web APIs, but building loosely coupled distributed systems without following strict contracts is a real challenge.
In the next video, we're going to take a closer look at the unique technologies of the RESTful web services development on the JVM platform.
Embark on an exciting journey into the universe of web development using the Scala programming language and frameworks—natural choices for back-end developers building highly scalable, reliable, and reactive RESTful web services and APIs. This training is the starting point for mastering the nonblocking and asynchronous programming models that lie in the heart of the Spray framework. It starts with an introduction to the REST architecture. Then switch gears to the Akka toolkit and framework, building a sample book catalog application along the way.
Once you've learned about the REST architectural style and Actor model—the foundations that the Spray framework is built upon—you'll shape out your own RESTful web services by providing simple route definitions. Further on in the course, author Andriy Redko delves into authentication and authorization, secure transport, documentation, testing, and caching support. Finally, you will learn how to develop the Spray client API to call external web services.
- The Actor model and Akka framework
- RESTful architecture principles and constraints
- Building RESTful services
- Core Spray framework modules such as spray-can, spray-routing, spray-json, spray-caching, and spray-client
- Securing RESTful web services and APIs with Spray
- Configuring Spray applications with HTTPS support
- Documenting Spray RESTful web services using Swagger
- Caching basics
- Calling external RESTful services