Hello there,
I have used spray-io in the past and am new to akka-http. I have a question
on writing directive/route that helps to intercept some / all end-points to
write some useful logging (for now and may be add some headers and other
stuff later).
While I was writing code with spray-io I had..
def clockTimeTaken: Directive0 = {
mapRequestContext { ctx =>
val startTime = System.currentTimeMillis()
log.mdc(Map("httpUrl" -> ctx.request.uri.toRelative.toString(),
"httpMethod" -> ctx.request.method.name)) //add to actor logging.
log.info(s"Started to service request")
ctx.withHttpResponseMapped { response =>
log.info(s"Completed HTTP in ${DateUtils.prettyPrintTimeTaken(startTime)}
[${response.messagePart}]")
log.clearMDC()
response
}
}
}
Any pointers on how I could rewrite this would help.
Thanks,
Muthu
--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ:
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.