Some More Routes
Explore how to create new product routes and return all products using Akka-HTTP and streaming in Scala. Understand the challenges of in-memory operations, learn to stream database results, group product data, and optimize endpoints for better performance and scalability.
We'll cover the following...
Creating a new product
Let’s create a new product.
As you can see, the function is basically the same as the one for updating a product, except we’re calling a different function from the repository.
Returning all products
Let’s now take a look at the “return all products” endpoint.
This looks more complicated than the other endpoints. So, what exactly are we doing here? Well, first we load the raw product data from the repository (Line ). After that, we convert it into the proper data model — or into a list of product entities, to be more exact. What is wrong with that approach?
- Firstly, we are performing operations in memory. This is