How it works...
In this recipe, we created a small HTTP server using HttpApp. This trait provides all of the code required to run a minimal HTTP server. When we extend the trait in our object, we need to implement routes, which define how to handle your incoming HTTP requests and respond to them. It is in routes that we can add different HTTP endpoints using directives. Directives are small code blocks and can be composed to form routes. In our example, we used the directives pathPrefix, path, get, post, and entity. As you can see, routing DSL is powerful and straightforward. Just by looking at the route definition, you understand how a request is going to be handled. We will see routing DSL in more depth in the Writing routing DSL for http ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access