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.client3" %% "async-http-client-backend-scalaz" % "3.1.0"
This backend depends on async-http-client and uses Netty behind the scenes.
Next you’ll need to add an implicit value:
import sttp.client3._
import sttp.client3.asynchttpclient.scalaz.AsyncHttpClientScalazBackend
AsyncHttpClientScalazBackend().flatMap { backend => ??? }
// or, if you'd like to use custom configuration:
import org.asynchttpclient.AsyncHttpClientConfig
val config: AsyncHttpClientConfig = ???
AsyncHttpClientScalazBackend.usingConfig(config).flatMap { 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 { backend => ??? }
// or, if you'd like to instantiate the AsyncHttpClient yourself:
import org.asynchttpclient.AsyncHttpClient
val asyncHttpClient: AsyncHttpClient = ???
val backend = AsyncHttpClientScalazBackend.usingClient(asyncHttpClient)
Websockets¶
The backend doesn’t support websockets.