尝试向Scala Play添加多个标头! WS请求:
WS
.url(requestUri)
.withHeaders("Authorization" -> ("Oauth %s" format(cred.authorizedToken)),
"Content-Type" -> "application/json")
.post(httpBody.get)
但目前失败了。什么是正确的语法?我尝试了多种方法,但编译器抱怨java字符串。谢谢!
答案 0 :(得分:3)
Ok("Hello World!").withHeaders(
CACHE_CONTROL -> "max-age=3600",
ETAG -> "xx"
)
方法定义也验证了你的代码:
def withHeaders(hdrs: (String, String)*)
// Parameters are infinite couples of String