I have a controller:
class HomeController @Inject() (cc: ControllerComponents) extends AbstractController(cc)with Logging
{
this: SecuredActionByToken =>
def index = CheckedToken{ ...
Where SecuredActionByToken
trait
is using class names CheckTokenService
to verify that user can run 'index' (we are trying to move from kind of cake pattern to Guice).
Is it possible to inject CheckTokenService
to SecuredActionByToken
? Of course, I could inject it to HomeController
itself and work somehow with it, but I don't really want to push some services to controllers when they don't directly use them.
i ended up creating my own provider for this bean, this way I can inject service directly to provider and use it in overriden trait method:
plus binding:
I can also test is by creating homeController like this: