【发布时间】:2013-06-26 12:36:14
【问题描述】:
我想“更改”在controllers.Assets.at 上设置的标题。
- 我想添加一个自定义标签(我可以通过
withHeaders执行此操作,如here 解释) -
我想删除之前设置的标签。如
Etag
由于.withHeaders 附加或覆盖现有标题,我无法使用它删除。对于 Cookie,有 discardingCookies,但我看不到类似的标题。
由于header: ResponseHeader 是val 中的val,因此我无法直接更改其值。
如何在 Play Framework 2.x Scala 中删除已设置的标签?
我正在尝试做的代码示例:
def at(file: String): Action[AnyContent] = CacheForever(Assets.at(assetDistDirectory, file))
def CacheForever[A](action: Action[A]): Action[A] = Action(action.parser) { request =>
action(request) match {
case s: SimpleResult[_] => {
s.withHeaders(
"mycustomheader" -> "is_set_here"
)
s.withOutHeaders("Etag","AnotherTagSetByAssetsAtButIDontWant")
// <--- I need something like the above line.
}
case result => result
}
}
【问题讨论】:
标签: scala playframework playframework-2.1