-
-
Save ezhulkov/90d050a0701206d318999f2995f14472 to your computer and use it in GitHub Desktop.
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
@Singleton | |
class TestController @Inject()( | |
loggingAction1: LoggingAction1, | |
loggingAction2: LoggingAction2, | |
val controllerComponents: ControllerComponents | |
) extends BaseController { | |
def StackAction = loggingAction1 andThen loggingAction2 | |
def index = StackAction { rq: Request[_] => | |
Ok(s"index page") | |
} | |
} | |
class LoggingAction1 @Inject()(parser: BodyParsers.Default)(implicit ec: ExecutionContext) extends ActionBuilderImpl(parser) { | |
override def invokeBlock[A](request: Request[A], block: (Request[A]) => Future[Result]) = { | |
Logger.info("Hello from LoggingAction1") | |
block(request) | |
} | |
} | |
class LoggingAction2 @Inject()(parser: BodyParsers.Default)(implicit ec: ExecutionContext) extends ActionBuilderImpl(parser) { | |
override def invokeBlock[A](request: Request[A], block: (Request[A]) => Future[Result]) = { | |
Logger.info("Hello from LoggingAction2") | |
block(request) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment