我正在一个播放scala应用程序中编写一个端点,该应用程序发出请求,在track
,album
和artist
类型中进行搜索。我想完成它们并将字符串转换为Future
的调用。
这是我的代码:
def index = Action.async { implicit request =>
val futures = List("track", "album", "artist")
.map { type => performSearch("q" -> param(request, "q"), "type" -> type) }
Future.sequence(futures).onComplete {
Ok
}
}
private def performSearch(criteria: (String, String)): Future = {
ws.url("https://api.spotify.com/v1/search")
.withQueryString(criteria)
.get()
}
private def param(request: Request[AnyContent], name: String): String = {
request.queryString.get(name).flatMap(_.headOption).getOrElse("")
}
但是我的地图中出现错误:
identifier expected but '=>' found
// .map { type => performSearch("q" -> param(request, "q"), "type" -> type) }
答案 0 :(得分:2)
LoginViewController
是一个关键字。选择其他东西或将其放入`:
type