The Scala programming language has gained a lot of traction in the last couple of years because of its functional orientation and conciseness. The industry has a strong interest in using Scala in modern production systems, and as such, the Spray framework and Akka toolkit became a natural choice for back-end Scala developers building highly-scalable, reliable, reactive REST(ful) web services and APIs.
This video course will be an exciting journey into the universe of the web development using the Scala programming language and frameworks. It is a starting point from which you'll learn the basics of building REST(ful) web services and APIs using the non-blocking and asynchronous programming models that lie in the heart of the Spray framework. You’ll start off by learning about the REST architecture. After that, you will switch gears to the Akka toolkit and Spray framework, building the 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 REST(ful) web services by providing simple route definitions. Further on, we'll delve into authentication, authorization, secure transport, documentation, test cases, and caching support. Finally, you will learn how to develop the Spray client API.
About The Author
Andriy Redko is a seasoned software developer and blogger, and is very
passionate about technology and software development in general.
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.
In this video, we are going to take a look at the state of REST(ful) web service development on the JVM platform to understand what options are available at the moment.
In this video, we are going to discuss the challenges of concurrent and parallel programming, which is heavily based on multithreading and mutable shared state. We will try to look around and find out whether there are other options available to overcome these challenges.
Traditional concurrent and parallel programming using thread pools and synchronization is hard to implement correctly. Understand the fundamentals and benefits of the Actor model and message passing concurrency.
Look for available Actor model implementations on the JVM platform. Get familiarized with the Akka framework (or toolkit), one of the popular implementations of the Actor model written completely in Scala.
Spray is very feature-rich framework that could be exploited in a couple of different ways. Our goal is to understand the Spray philosophy, foundations, and design principles along with versioning policy.
Learn the traditional way of handling HTTP requests in Spray using Scala pattern matching and understand its weak points. Discover the alternative high-level abstractions in a form of routes and directives.
Defining REST(ful) web service endpoints is really very easy using Spray Routing. However, it is equally important to support right data representation and be ready to dial with failure conditions.
In the modern web architecture, HTTP servers and clients play a key role in exposing and consuming REST(ful) Web services. Spray Can fills this niche by providing high-performance HTTP/1.1 servers and client implementations.
It is possible to use different programming languages and frameworks to access REST(ful) Web services and APIs but it requires at least some basic knowledge. From the other side, browsers and command line tools are available everywhere.
Unfortunately, security flaws leading to unauthorized access to massive volumes of private and confidential data are not as rare as we would like them to be. That is why these days built-in security mechanisms are first-class features of the modern REST(ful) Web services and APIs.
Authentication helps a lot with answering the question about who is accessing the system. However, in most cases, this is not enough as the next challenge to solve is what the authenticated user is allowed to do?
Inherently, the HTTP protocol is text-based and does not prevent data interception or tampering. Secure HTTP (HTTPS) is based on transport level security (TLS) and uses encryption to protect the transmitted data.
A well-written web service or API that no one knows how to use is not worth much. Proper documentation is an integral part of any REST(ful) web service.
Swagger does not officially support the Spray framework yet, but there is a community project that provides all the required integrations.
In most cases, the Swagger API exposes REST(ful) web services and APIs’ documentation using JSON or XML formats. This is great but not very comfortable for a human to work with.
Delivering high-quality software (including web services and APIs) should be a primary goal of any software developer. Test-driven development practices aim to raise the bar of the quality by writing the test suites along with the main code.
Spray TestKit provides a nice DSL for testing web services and APIs built on top of Spray Routing. But Spray TestKit cannot be used alone and requires ScalaTest or Specs2 libraries.
Complex computations and accessing external systems (such as relational data stores, for example) could be costly and time-consuming. Caching is one of the most effective techniques to mitigate this cost.
Implementing effective caching algorithms from scratch could take a lot of time and effort. Luckily, there are quite a few proven strategies to deal with caching that the Spray framework provides out of the box.
Most REST(ful) web services and APIs do not exist in isolation but have to call other external REST(ful) web services and APIs.
Integrations with external systems (including web services) introduce some complications into the testability aspects of applications. Not only could it have side effects, but also calling external systems within the test case introduces a high level of instability.
Packt has been committed to developer learning since 2004. A lot has changed in software since then - but Packt has remained responsive to these changes, continuing to look forward at the trends and tools defining the way we work and live. And how to put them to work.
With an extensive library of content - more than 4000 books and video courses -Packt's mission is to help developers stay relevant in a rapidly changing world. From new web frameworks and programming languages, to cutting edge data analytics, and DevOps, Packt takes software professionals in every field to what's important to them now.
From skills that will help you to develop and future proof your career to immediate solutions to every day tech challenges, Packt is a go-to resource to make you a better, smarter developer.
Packt Udemy courses continue this tradition, bringing you comprehensive yet concise video courses straight from the experts.