1
我有我在玩2.5應用程序的大多數REST端點使用ActionBuilder:如何保護與授權ActionBuilder靜態文件在播放2.5框架
def IfAuthorized(auths: Authorizations*): ActionBuilder[AuthRequestWithAuthorization] = {
new MyAuthActionBuilder(auths.toList)
}
,我可以爲使用:
def status = IfAuthorized(Editor).async { implicit authReq =>
//eventually return Result
}
現在我想要在同一個ActionBuilder
中包裝靜態文件請求。目前我使用這個oneliner,這使我成爲HTML,JS,CSS等,全部返還/緩存沒有我的干擾:
GET /ui/*file controllers.Assets.versioned(path="/public", file: Asset)
我不知道如何在ActionBuilder推。一個可憐的試圖返回初始HTML頁面包括:
def index()= IfAuthorized(Editor) { authReq =>
val contentStream = this.getClass.getResourceAsStream("/public/index.html")
Ok.chunked(Enumerator.fromStream(contentStream)).as(HTML)
}
這Action
只能夠返回一個特定的HTML文件,而我想從1條路線返回的所有靜態資產,通過我的自定義保護ActionBuilder