play.api.mvc 中的对象 Action 在哪里?
Where is the object Action in play.api.mvc?
我是Play Framework的新手。当我在它的网页上学习它时。我发现了一些这样的代码:
import play.api.mvc._
def logging[A](action: Action[A]) = Action.async(action.parser) { request =>
logger.info("Calling action")
action(request)
}
我查看了它的文档,在ActionBuilder
中有一个函数async
。
Action.async
是如何运作的? play.api.mvc
中似乎没有对象 Action
object Action
已在 Play 2.8 中被 Remove deprecated play.api.mvc.Action #9288, and has been replaced by BaseController.Action
method which refers to injected controllerComponents.actionBuilder
而不是全局对象
移除
/**
* ...
* This is meant to be a replacement for the now-deprecated Action object, and can be used in the same way.
*/
def Action: ActionBuilder[Request, AnyContent] = controllerComponents.actionBuilder
请注意,方法名称以大写字母开头,这可能是非常规的。我的假设是这样做是为了保持熟悉的用法
def foo(query: String) = Action {
Ok
}
我是Play Framework的新手。当我在它的网页上学习它时。我发现了一些这样的代码:
import play.api.mvc._
def logging[A](action: Action[A]) = Action.async(action.parser) { request =>
logger.info("Calling action")
action(request)
}
我查看了它的文档,在ActionBuilder
中有一个函数async
。
Action.async
是如何运作的? play.api.mvc
Action
object Action
已在 Play 2.8 中被 Remove deprecated play.api.mvc.Action #9288, and has been replaced by BaseController.Action
method which refers to injected controllerComponents.actionBuilder
而不是全局对象
/**
* ...
* This is meant to be a replacement for the now-deprecated Action object, and can be used in the same way.
*/
def Action: ActionBuilder[Request, AnyContent] = controllerComponents.actionBuilder
请注意,方法名称以大写字母开头,这可能是非常规的。我的假设是这样做是为了保持熟悉的用法
def foo(query: String) = Action {
Ok
}