Question

Hi I am turning here as a last resort but I'm at my wits end. I was trying to learn dispatch so I can do my next web project in scala but I can't even make it past the tutorial. This is what I'm trying to do.

import dispatch._
val h = new Http
val req = url("http://www.scala-lang.org/")
val handler = req >>> System.out

In the sbt console the first 3 lines work correctly but I get an error on the last that value >>> is not a member of com.ning.http.client.RequestBuilder@6eb7546d. Googling this error has honestly been less than insightful. When trying to put this into a .scala file and run it It errors out on the import dispatch._ line. I honestly have no idea what I'm doing wrong here and would kill for some help right now. This can't be as hard as it seems. Also I've installed sbt and followed these directions found at the dispatch home page:

echo 'libraryDependencies += 
  "net.databinder.dispatch" %% "dispatch-core" % "0.9.5"' > build.sbt
sbt console

I additionally have a build.sbt folder containing the following

libraryDependencies +=
"net.databinder.dispatch" %% "dispatch-core" % "0.9.5"
Was it helpful?

Solution

My best bet is that you're referring to some old tutorial for an outdated version of the library.

Version 0.9.x was totally revised wrt 0.8.x

I suggest you look at the dispatch page and follow the simple steps provided there.

OTHER TIPS

If you're at your wits end with Dispatch, so was I. So here's a shameless plug for my alternative Bee-Client HTTP client api:

val httpClient = new HttpClient
val response: Response = httpClient.get("http://www.google.com/")
println(response.status)
println(response.body.asString)

It's explicitly simple and blocking. If you want non-blocking requests, just wrap the calls in futures.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top