Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/scala/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Scala Play 2.5动作合成与死锁-2动作_Scala_Playframework_Deadbolt 2 - Fatal编程技术网

Scala Play 2.5动作合成与死锁-2动作

Scala Play 2.5动作合成与死锁-2动作,scala,playframework,deadbolt-2,Scala,Playframework,Deadbolt 2,我正在处理Scala Play应用程序,需要许多控制器操作,通过在响应的HTTP头中设置参数来禁用浏览器缓存。我决定创建一个NoCache复合动作,因为我也在使用Deadbolt-2(并且需要Deadbolt-2的AuthenticatedRequest[\u]),它看起来像这样: package action import be.objectify.deadbolt.scala.AuthenticatedRequest import play.api.http.HeaderNames imp

我正在处理Scala Play应用程序,需要许多控制器操作,通过在响应的HTTP头中设置参数来禁用浏览器缓存。我决定创建一个
NoCache
复合动作,因为我也在使用Deadbolt-2(并且需要Deadbolt-2的
AuthenticatedRequest[\u]
),它看起来像这样:

package action

import be.objectify.deadbolt.scala.AuthenticatedRequest
import play.api.http.HeaderNames
import play.api.mvc._

import scala.concurrent.Future
import scala.util.Success

case class NoCache[A](action: Action[A]) extends Action[A] with HeaderNames {
  def apply(request: AuthenticatedRequest[A]): Future[Result] = {
    action(request).andThen {
      case Success(result) => result.withHeaders(
        (CACHE_CONTROL -> "no-cache, no-store, must-revalidate"),
        (PRAGMA -> "no-cache"),
        (EXPIRES -> "0")
      )
    }
  }

  lazy val parser = action.parser
}
但如果尝试将此操作混合到控制器操作实现中,则不会编译

def link = deadbolt.SubjectPresent()() andThen NoCache() { implicit request =>


但是看不到如何组合它们…

我发现如何在单个动作中组合它们:

def index = NoCache {
  deadbolt.WithAuthRequest()() { implicit request =>
    Future {
      Ok(views.html.index(userService))
    }
  }
} 

但是,我仍然没有找到如何将
NoCache
应用于整个控制器类。

找到解决方案了吗?我也有同样的问题,把游戏动作和死锁动作结合起来
def index = NoCache {
  deadbolt.WithAuthRequest()() { implicit request =>
    Future {
      Ok(views.html.index(userService))
    }
  }
}