title: Interceptors/Filters in Spray
body: <p>I'm busy migrating one of our Spring/Groovy applications to Spray/Scala. I'm fairly new to Spray, so forgive me if this is a beginner question.  </p>
  
  <p>The objective is to emulate our logging Interceptor, which logs various data for every request/response.  There is quite a lot of logic that goes on in this part of the code, so its not a simple log line. Also, I'd like to wrap ALL requests that come in with this logic.</p>
  
  <p>Existing Groovy/Spring Interceptor:</p>
  
  <pre><code>boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler {
    //do some logging logic
  }
  
  
  void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
    //do some more logging logic
  }
  </code></pre>
  
  <p>My Scala actor looks like this</p>
  
  <pre><code>class BootServiceActor extends Actor with ViewingController with LazyLogging with ViewingWire {
  
  def actorRefFactory = context
  
  implicit val ctx = context.dispatcher
  
  def receive = runRoute(route)(exceptionHandler, RejectionHandler.Default, context,
    RoutingSettings.default, LoggingContext.fromActorRefFactory)
  }
  </code></pre>