Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@dabd
Last active May 12, 2019 19:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dabd/a9af4dfa2825a30c86cedcd0d83e2c5c to your computer and use it in GitHub Desktop.
Save dabd/a9af4dfa2825a30c86cedcd0d83e2c5c to your computer and use it in GitHub Desktop.
trait ActionBuilder2[+R[_]] extends ActionBuilder[R] { self =>
def async2(block: => Task[Result]): Action[AnyContent] =
async(block runAsync)
def async2(block: R[AnyContent] => Task[Result]): Action[AnyContent] =
async(block(_) runAsync)
def async2[A](bodyParser: BodyParser[A])(block: R[A] => Task[Result]): Action[A] =
async(bodyParser)(block(_) runAsync)
def andThen2[Q[_]](other: ActionFunction[R, Q]): ActionBuilder2[Q] = new ActionBuilder2[Q] {
def invokeBlock[A](request: Request[A], block: Q[A] => Future[Result]): Future[Result] =
self.invokeBlock[A](request, other.invokeBlock[A](_, block))
override protected def composeParser[A](bodyParser: BodyParser[A]): BodyParser[A] =
self.composeParser(bodyParser)
override protected def composeAction[A](action: Action[A]): Action[A] =
self.composeAction(action)
}
}
trait ActionFilter2[R[_]] extends ActionFilter[R] {
override final protected def filter[A](request: R[A]): Future[Option[Result]] = {
filter2(request) runAsync
}
def filter2[A](request: R[A]): Task[Option[Result]]
}
trait ActionRefiner2[-R[_], +P[_]] extends ActionRefiner[R, P] {
override final protected def refine[A](request: R[A]): Future[Either[Result, P[A]]] =
refine2(request) runAsync
def refine2[A](request: R[A]): Task[Either[Result, P[A]]]
}
@henricook
Copy link

For anyone else reading this, it would appear to be for an older version of Play (pre 2.7)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment