Created
March 11, 2014 08:31
-
-
Save zygm0nt/9481663 to your computer and use it in GitHub Desktop.
scala spray route debugging
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait AbcService with UnhandledRouteDebug { | |
override def receive: Actor.Receive = runRoute(logRequestResponse(myLog _) { | |
staticRoute ~ internalRoutes ~ routes | |
}) | |
} | |
trait UnhandledRouteDebug { | |
def myLog(request: HttpRequest): Any => Option[LogEntry] = { | |
case x: HttpResponse => { | |
println (s"Normal: $request") | |
createLogEntry(request, x.status + " " + x.toString()) | |
} | |
case Rejected(rejections) => { | |
println (s"Rejection: $request") | |
createLogEntry(request, " Rejection " + rejections.toString()) | |
} | |
case x => { | |
println (s"other: $request") | |
createLogEntry(request, x.toString()) | |
} | |
} | |
def createLogEntry(request: HttpRequest, text: String): Some[LogEntry] = { | |
Some(LogEntry("#### Request " + request + " => " + text, DebugLevel)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment