Debugging

Just needed it when I was developing my routes and couldn't figure out why my route didn't get picked up.

The reason turned out to be the path I was using - instead of /a/b/c I mistakenly used a mere /. It causes no route to be selected.

Spray comes with a directive to help you learn about the upcoming requests and outgoing responses in DebuggingDirectives trait, namely logRequest, logRequestResponse and logResponse, and when properly placed could help you out with developing your own proper routes.

val route: Route =
  pathPrefix(separateOnSlashes("api/dict/rules")) {
    logRequest("api/dict/rules", Logging.InfoLevel) {
      timerRoutes ~ searchGetRoutes ~ pathIntRoutes ~ mainRoutes
    }
  }

With the above, you should see in the logs:

dictionary-spray [INFO] [12/13/2014 23:44:26.685] [default-akka.actor.default-dispatcher-2] [ActorSystem(default)] api/dict/rules: HttpRequest(PUT,http://localhost:8080/api/dict/rules/a/b?timer=4,List(Accept: /, Host: localhost:8080, User-Agent: curl/7.37.1),Empty,HTTP/1.1)

results matching ""

    No results matching ""