Scalaz backend

The Scalaz backend is asynchronous. Sending a request is a non-blocking, lazily-evaluated operation and results in a response wrapped in a scalaz.concurrent.Task. There’s a transitive dependency on scalaz-concurrent.

To use, add the following dependency to your project:

"com.softwaremill.sttp.client" %% "async-http-client-backend-scalaz" % "2.2.1"

This backend depends on async-http-client and uses Netty behind the scenes.

Next you’ll need to add an implicit value:

import sttp.client._
import sttp.client.asynchttpclient.scalaz.AsyncHttpClientScalazBackend

AsyncHttpClientScalazBackend().flatMap { implicit backend => ??? }

// or, if you'd like to use custom configuration:
import org.asynchttpclient.AsyncHttpClientConfig
val config: AsyncHttpClientConfig = ???

AsyncHttpClientScalazBackend.usingConfig(config).flatMap { implicit backend => ??? }

// or, if you'd like to use adjust the configuration sttp creates:
import org.asynchttpclient.DefaultAsyncHttpClientConfig
val sttpOptions: SttpBackendOptions = SttpBackendOptions.Default  
val adjustFunction: DefaultAsyncHttpClientConfig.Builder => DefaultAsyncHttpClientConfig.Builder = ???

AsyncHttpClientScalazBackend.usingConfigBuilder(adjustFunction, sttpOptions).flatMap { implicit backend => ??? }

// or, if you'd like to instantiate the AsyncHttpClient yourself:
import org.asynchttpclient.AsyncHttpClient
val asyncHttpClient: AsyncHttpClient = ???

implicit val sttpBackend = AsyncHttpClientScalazBackend.usingClient(asyncHttpClient)

Streaming

This backend doesn’t support non-blocking streaming.

Websockets

The backend supports websockets by wrapping a low-level Java interface, sttp.client.asynchttpclient.WebSocketHandler.