Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* Copyright (C) from 2022 The Play Framework Contributors <https://github.com/playframework>, 2011-2021 Lightbend Inc. <https://www.lightbend.com>
*/

package play.api.mvc

trait ActionBuilderMethods[+R[_], B] { self: ActionBuilder[R, B] =>

}
28 changes: 28 additions & 0 deletions core/play/src/main/scala-3/play/api/mvc/ActionBuilderMethods.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright (C) from 2022 The Play Framework Contributors <https://github.com/playframework>, 2011-2021 Lightbend Inc. <https://www.lightbend.com>
*/

package play.api.mvc

import scala.concurrent.Future

trait ActionBuilderMethods[+R[_], B] { self: ActionBuilder[R, B] =>

/**
* Constructs an `Action` that returns a future of a result, with default content.
*
* @param block the action code
* @return an action
*/
final def handle(block: R[B] ?=> Future[Result]): Action[B] =
async(request => block(using request))

/**
* Constructs an `Action` with the given [[BodyParser]] that returns a future of a result.
*
* @param block the action code
* @return an action
*/
final def handle[A](bodyParser: BodyParser[A])(block: R[A] ?=> Future[Result]): Action[A] =
async(bodyParser)(request => block(using request))
}
2 changes: 1 addition & 1 deletion core/play/src/main/scala/play/api/mvc/Action.scala
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ trait ActionFunction[-R[_], +P[_]] {
/**
* Provides helpers for creating [[Action]] values.
*/
trait ActionBuilder[+R[_], B] extends ActionFunction[Request, R] {
trait ActionBuilder[+R[_], B] extends ActionFunction[Request, R] with ActionBuilderMethods[R, B] {
self =>

/**
Expand Down
Loading