For this recipe, perform the following steps:
- First, start writing a trait that will handle all the requests for a given path and leave the methods for handling get, post, put, and delete requests unimplemented. Create a file named InMemoryStorageRestApi.scala inside the com.packt.chapter9 package with the following content:
package com.packt.chapter9 import akka.http.scaladsl.server.Directives._ import akka.http.scaladsl.server._ import scala.collection.mutable trait InMemoryStorageRestApi[K, V] { implicit val fixedPath: String def composedRoute(cache: mutable.Map[K, V]) = versionOneRoute { temperaturePathRoute { handleAllMethods(cache) } } private def versionOneRoute(route: Route) = pathPrefix("v1") { route } private ...