Handler which wraps Handler/Future[Handler]

I’m using compile time dependency injection in my app and create my routes using SIRD.
What I tried to achieve was kind of a filter that I can strictly apply to one or more Routes object/Router simply by wrapping the Routes/Router.

I’ve created this by implementing a Routes which is wrapping the existing Routes in here: https://gist.github.com/domdorn/0babae52f9a96b1db6e38aa77690edbf

In my code, I’m calling a future and then mapping … unfortunately, there is no existing Handler thats able to return/wrap a Future[Handler] ( EssentialAction allows me to return Future[Result] / Accumulator[ByteString, Result] ), so at the moment, I have to do a Await.result() on the future :(

I thought about creating a own Handler (e.g. like EssentialAction) that is able to wrap a Handler and do the proper lifting/future handling, but I think I’d either have to change


to make this work.

Any input would be highly appreciated.
And yes, I know I could create a normal play.api.mvc.Filter, but that is not the question here.