softwaremill / sttp

The Scala HTTP client you always wanted!
https://sttp.softwaremill.com
Apache License 2.0
1.44k stars 301 forks source link

could not import AsyncHttpClientScalazBackend #80

Closed prayagupa closed 6 years ago

prayagupa commented 6 years ago

I'm trying to use scalaz backend for my sttp but could not find one. Here's my sbt

name := "customer-order-specs"

version := "0.1"

scalaVersion := "2.12.5"

libraryDependencies += "com.softwaremill.sttp" %% "core" % "1.1.12"
libraryDependencies += "com.softwaremill.sttp" %% "async-http-client-backend" % "1.1.12"

libraryDependencies += "com.softwaremill.sttp" %% "async-http-client-handler-scalaz" % "0.0.13"

libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.0-SNAP10" % Test

libraryDependencies += "org.scalacheck" %% "scalacheck" % "1.13.4" % "test"

I do not see ScalazBackend in async-http-client-handler-scalaz.jar.

screen shot 2018-04-21 at 6 47 06 pm

I'm trying to simple scalaz backed http client example, as described in README with HttpURLConnectionBackend

  test("scalaz example") {
    import com.softwaremill.sttp.asynchttpclient.scalaz._

    implicit val backend: SttpBackend[Id, Nothing] = AsyncHttpClientScalazBackend()
    val httpRequest = sttp
      .post(uri"http://httpbin.org/post")
      .body("Hello, world!")

    val httpResponse = httpRequest.send()

    httpResponse.body.isRight shouldBe true
  }
prayagupa commented 6 years ago

Nevermind, I needed async-http-client-backend-scalaz which I could not find in the README at all but somehow mentioned in https://softwaremill.com/introducing-sttp-the-scala-http-client/

libraryDependencies += "com.softwaremill.sttp" %% "async-http-client-backend-scalaz" % "1.1.12"

Also the blog - https://softwaremill.com/introducing-sttp-the-scala-http-client/ probably needs to be updated.

from

implicit val backend = HttpURLConnectionSttpBackend()

to

implicit val backend = HttpURLConnectionBackend()
adamw commented 6 years ago

Ah, it's currently listed on http://sttp.readthedocs.io/en/latest/backends/asynchttpclient.html, but maybe it's not that obvious. Where did you look? :)