Discussions

Ask a Question
Back to All

Mixing Deadbolt with Play cached Actions

https://www.playframework.com/documentation/2.6.x/ScalaCache#Caching-HTTP-responses

Any advice on how best to mix the two in a controller function? e.g.


def aCacheableResponse(id: String) = 
  deadbolt.SubjectPresent()() { implicit request =>
    cached((_: RequestHeader) => s"something.$id", 1.hour) {
      Action.async {
        //do some stuff here, get a future result
      }
    }
  }

doesnt work, but is there something similar to this I can try?