I need to pass some information down the call stack in a Scala Play application.
For example:
class FooController: play.api.mvc.BaseController {
...
def method1(request: play.mvc.Http.Request) = {
// Somehow store the request.callerId
// I need to access it whenever I need to know the caller. For example, I will need it for some logging.
fooService.method2()
}
}
class FooService {
...
def method2() = fooRepository.method3()
}
class FooRepository {
...
def method3() = {
// I want to access the callerId to log who made the changes
}
}
I need to know who started the call down the call stack. Is it possible without changing the code and adding extra parameters to all methods?
Note: I use Scala 2.13 and play 3.0