From e5ebd242a4cb982af6b01ec1976ecfc91398189f Mon Sep 17 00:00:00 2001 From: adamw Date: Fri, 21 Jul 2017 16:40:07 +0200 Subject: Scalaz version of the async http client handler, wrapping responses in a Task --- README.md | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 357142e..b5b62e9 100644 --- a/README.md +++ b/README.md @@ -240,24 +240,33 @@ val response: Future[Response[Source[ByteString, Any]]] = To use, add the following dependency to your project: ```scala -"com.softwaremill.sttp" %% "async-http-client-handler" % version +"com.softwaremill.sttp" %% "async-http-client-handler-future" % version +// or +"com.softwaremill.sttp" %% "async-http-client-handler-scalaz" % version ``` This handler depends on [async-http-handler](https://github.com/AsyncHttpClient/async-http-client). A fully **asynchronous** handler, which uses [Netty](http://netty.io) behind the -scenes. Sending a request returns a response wrapped in a `Future`. Different -wrappers will be added in the future. +scenes. + +The responses are either wrapped in a `Future`, or a +[Scalaz](https://github.com/scalaz/scalaz) `Task`, depending on the +dependency chosen. In the latter case, there's an additional transitive +dependency on `scalaz-concurrent`. Next you'll need to add an implicit value: ```scala -implicit val sttpHandler = new AsyncHttpClientHandler() +implicit val sttpHandler = new FutureAsyncHttpClientHandler() + +// or, if you're using the scalaz version: +implicit val sttpHandler = new ScalazAsyncHttpClientHandler() // or, if you'd like to use custom configuration: -implicit val sttpHandler = new AsyncHttpClientHandler(asyncHttpClientConfig) +implicit val sttpHandler = new FutureAsyncHttpClientHandler(asyncHttpClientConfig) // or, if you'd like to instantiate the AsyncHttpClient yourself: -implicit val sttpHandler = new AsyncHttpClientHandler(asyncHttpClient) +implicit val sttpHandler = new FutureAsyncHttpClientHandler(asyncHttpClient) ``` Streaming is not (yet) supported. -- cgit v1.2.3