Play 2.2 EssentialAction With Futures
问题 I'm trying to implement an authentication mechanism similar to this example: def HasToken(action: String => EssentialAction): EssentialAction = EssentialAction { requestHeader => val maybeToken = requestHeader.headers.get("X-SECRET-TOKEN") maybeToken map { token => action(token)(requestHeader) // apply requestHeader to EssentialAction produces the Iteratee[Array[Byte], SimpleResult] } getOrElse { Done(Unauthorized("401 No Security Token\n")) // 'Done' means the Iteratee has completed its