How it works...
In this recipe, we learned how to use the Akka HTTP routing DSL. We created a REST API to store the temperature values of various locations. To achieve this, we created a generalized trait: InMemoryStorageRestApi. This trait composes a route by matching all the incoming requests with two pathPrefix directives. The first one is the version prefix v1 that is used primarily to provide some versioning mechanism to our API (there is currently no universally accepted way of versioning your API, and this is just one of the common approaches). The second one is just a string we use to identify the resources in the URI path. After this, we had four unimplemented methods to handle the different HTTP methods. They matched, thanks to ...
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