diff options
Diffstat (limited to 'async-http-client-backend/scalaz/src/main/scala/com/softwaremill/sttp')
-rw-r--r-- | async-http-client-backend/scalaz/src/main/scala/com/softwaremill/sttp/asynchttpclient/scalaz/AsyncHttpClientScalazBackend.scala | 28 |
1 files changed, 3 insertions, 25 deletions
diff --git a/async-http-client-backend/scalaz/src/main/scala/com/softwaremill/sttp/asynchttpclient/scalaz/AsyncHttpClientScalazBackend.scala b/async-http-client-backend/scalaz/src/main/scala/com/softwaremill/sttp/asynchttpclient/scalaz/AsyncHttpClientScalazBackend.scala index 7c2343d..db8731e 100644 --- a/async-http-client-backend/scalaz/src/main/scala/com/softwaremill/sttp/asynchttpclient/scalaz/AsyncHttpClientScalazBackend.scala +++ b/async-http-client-backend/scalaz/src/main/scala/com/softwaremill/sttp/asynchttpclient/scalaz/AsyncHttpClientScalazBackend.scala @@ -3,16 +3,16 @@ package com.softwaremill.sttp.asynchttpclient.scalaz import java.nio.ByteBuffer import com.softwaremill.sttp.asynchttpclient.AsyncHttpClientBackend -import com.softwaremill.sttp.{FollowRedirectsBackend, MonadAsyncError, SttpBackend, SttpBackendOptions} +import com.softwaremill.sttp.impl.scalaz.TaskMonadAsyncError +import com.softwaremill.sttp.{FollowRedirectsBackend, SttpBackend, SttpBackendOptions} import io.netty.buffer.ByteBuf import org.asynchttpclient.{AsyncHttpClient, AsyncHttpClientConfig, DefaultAsyncHttpClient} import org.reactivestreams.Publisher import scalaz.concurrent.Task -import scalaz.{-\/, \/-} class AsyncHttpClientScalazBackend private (asyncHttpClient: AsyncHttpClient, closeClient: Boolean) - extends AsyncHttpClientBackend[Task, Nothing](asyncHttpClient, TaskMonad, closeClient) { + extends AsyncHttpClientBackend[Task, Nothing](asyncHttpClient, TaskMonadAsyncError, closeClient) { override protected def streamBodyToPublisher(s: Nothing): Publisher[ByteBuf] = s // nothing is everything @@ -37,25 +37,3 @@ object AsyncHttpClientScalazBackend { def usingClient(client: AsyncHttpClient): SttpBackend[Task, Nothing] = AsyncHttpClientScalazBackend(client, closeClient = false) } - -private[scalaz] object TaskMonad extends MonadAsyncError[Task] { - override def unit[T](t: T): Task[T] = Task.point(t) - - override def map[T, T2](fa: Task[T])(f: (T) => T2): Task[T2] = fa.map(f) - - override def flatMap[T, T2](fa: Task[T])(f: (T) => Task[T2]): Task[T2] = - fa.flatMap(f) - - override def async[T](register: ((Either[Throwable, T]) => Unit) => Unit): Task[T] = - Task.async { cb => - register { - case Left(t) => cb(-\/(t)) - case Right(t) => cb(\/-(t)) - } - } - - override def error[T](t: Throwable): Task[T] = Task.fail(t) - - override protected def handleWrappedError[T](rt: Task[T])(h: PartialFunction[Throwable, Task[T]]): Task[T] = - rt.handleWith(h) -} |