title: Akka Http API singleton user context
body: <p>I am writing a REST API using Scala and Akka Http.</p>
  
  <p>For request handling, I implement Routes in the form of <code>RequestContext =&gt; Future[RouteResult]</code></p>
  
  <p>In each route, I have to pass the context of the user from function to function, which becomes a bit cumbersome.  For example, in the code below, I always have to pass <code>userContext</code> into every function that interacts with the DB.</p>
  
  <pre><code>val route: Route = {    
     requestContext =&gt; {
        val userContext = extractUser(requestContext)
        val computeResult = compute(userContext)
        requestContext.complete(computeResult)   
     } 
  }
  </code></pre>
  
  <p>However, if I set the context to a singleton, then it runs the risk of being overridden when the next calls comes in, since the API is multi-tenant.</p>
  
  <p>Is there a better way to handle this?</p>