0
下面是我的方法:WSRequest重試次數
def buildWSRequest(url: String, accessToken: String, wsClient: WSClient)
: (WSRequest, WSResponse) = {
import AppImplicits._
val d1 = new java.util.Date()
val request: WSRequest = wsClient.url(url)
.withHeaders("Authorization" -> ("Bearer " + accessToken))
.withHeaders("Content-type" -> "application/json", "Accept" -> "application/json; charset=utf-8")
var response: WSResponse = null
try {
val future = request.get()
response = scala.concurrent.Await.result(future, duration)
} catch {
case ex: Throwable => throw ex.getCause
}
return (request, response)
}
而我打電話的部分是:
var response: WSResponse = buildWSRequest("www.sampletest123.com", params.apply("accessToken").asInstanceOf[String], sslClient)._2
我想再試wsRequest
,n次,該怎麼做?
https://gist.github.com/viktorklang/9414163 –