我正在尝试从HTTP请求的授权标头中提取令牌。授权标头的格式为Authorization: Token token=abcdefg123
。我想有以下函数签名但是当我尝试下面的代码片段时,编译错误是Cannot resolve symbol Map. Cannot resolve method Map.unapply
。我不确定为什么会这样。任何帮助表示赞赏。
def extractToken(request: HttpRequest): Option[String] = {
for {
Authorization(GenericHttpCredentials("Token", "", Map("token"->token)))
<- request.header[Authorization]
} yield token
}
答案 0 :(得分:0)
找出一个工作函数,
private def extractToken(request: HttpRequest): Option[String] = {
for {
Authorization(GenericHttpCredentials("Token", "", params)) <- request.header[Authorization]
token <- params.get("token")
} yield token
}