我正在尝试使用 Scala Dispatch 执行一个简单的 GET 请求,但是出现 404 错误。意外响应状态:404
这是一个有效的示例:
https://www.google.com/finance/info?infotype=infoquoteall&q=tsla,goog
但是我是否知道我的错误在我的代码中的位置
import dispatch._ , Defaults._
object Main extends App {
//concats a the proper uri together to send to google finance
def composeUri ( l:List[String]) = {
def google = host("google.com").secure
def googleFinance = google / "finance" / "info"
def googleFinanceGet = googleFinance.GET
val csv = l mkString ","
googleFinanceGet <<? Map("infotype"-> "infoquoteall", "q"->csv)
}
def sendRequest (uri:Req) = {
val res:Future[Either[Throwable,String]] = Http(uri OK as.String).either
res
}
val future = sendRequest(composeUri(List("tsla","goog")))
for (f <- future.left) yield println("There was an error" + f.getMessage)
}
谢谢!