0
class AuthorizedFilter extends EssentialFilter {
private def authorizationRequired(request: RequestHeader) = {
val clientId = request.headers.get("clientId");
val id = "74f6df0452"; //to match with clientID.Block remaining request
clientId match {
case Some(id) =>
true;
case _ =>
false;
}
}
def apply(next: EssentialAction):EssentialAction = new EssentialAction {
def apply(request: RequestHeader) = {
println("result...",request.headers.get("clientId"));
if(!authorizationRequired(request)) {
*Iteratee.ignore[Array[Byte]].map(_ => Results.forbidden())*
}
else {
println("YOU are authorized!!")
next(request)
}
}
}
}
上面的過濾器被添加來阻止clientID不匹配的所有請求。我在Iteratee.ignore [Array [Byte]]。map(_ => Results.forbidden())中收到了錯誤消息。類型Iteratee [Array [Byte],StatusHeader]的表達式與Play scala中期望的類型Accumulater [Byte,Result]不一致?