diff options
Diffstat (limited to 'async-http-client-backend/cats/src/main')
-rw-r--r-- | async-http-client-backend/cats/src/main/scala/com/softwaremill/sttp/asynchttpclient/cats/AsyncHttpClientCatsBackend.scala | 25 |
1 files changed, 4 insertions, 21 deletions
diff --git a/async-http-client-backend/cats/src/main/scala/com/softwaremill/sttp/asynchttpclient/cats/AsyncHttpClientCatsBackend.scala b/async-http-client-backend/cats/src/main/scala/com/softwaremill/sttp/asynchttpclient/cats/AsyncHttpClientCatsBackend.scala index 506ad42..0e5955a 100644 --- a/async-http-client-backend/cats/src/main/scala/com/softwaremill/sttp/asynchttpclient/cats/AsyncHttpClientCatsBackend.scala +++ b/async-http-client-backend/cats/src/main/scala/com/softwaremill/sttp/asynchttpclient/cats/AsyncHttpClientCatsBackend.scala @@ -2,9 +2,10 @@ package com.softwaremill.sttp.asynchttpclient.cats import java.nio.ByteBuffer -import cats.effect._ +import cats.effect.Async import com.softwaremill.sttp.asynchttpclient.AsyncHttpClientBackend -import com.softwaremill.sttp.{FollowRedirectsBackend, MonadAsyncError, SttpBackend, SttpBackendOptions} +import com.softwaremill.sttp.impl.cats.AsyncMonadAsyncError +import com.softwaremill.sttp.{FollowRedirectsBackend, SttpBackend, SttpBackendOptions} import io.netty.buffer.ByteBuf import org.asynchttpclient.{AsyncHttpClient, AsyncHttpClientConfig, DefaultAsyncHttpClient} import org.reactivestreams.Publisher @@ -16,7 +17,7 @@ class AsyncHttpClientCatsBackend[F[_]: Async] private ( closeClient: Boolean ) extends AsyncHttpClientBackend[F, Nothing]( asyncHttpClient, - new AsyncMonad, + new AsyncMonadAsyncError, closeClient ) { override protected def streamBodyToPublisher(s: Nothing): Publisher[ByteBuf] = @@ -43,21 +44,3 @@ object AsyncHttpClientCatsBackend { def usingClient[F[_]: Async](client: AsyncHttpClient): SttpBackend[F, Nothing] = AsyncHttpClientCatsBackend(client, closeClient = false) } - -private[cats] class AsyncMonad[F[_]](implicit F: Async[F]) extends MonadAsyncError[F] { - - override def async[T](register: ((Either[Throwable, T]) => Unit) => Unit): F[T] = - F.async(register) - - override def unit[T](t: T): F[T] = F.pure(t) - - override def map[T, T2](fa: F[T])(f: (T) => T2): F[T2] = F.map(fa)(f) - - override def flatMap[T, T2](fa: F[T])(f: (T) => F[T2]): F[T2] = - F.flatMap(fa)(f) - - override def error[T](t: Throwable): F[T] = F.raiseError(t) - - override protected def handleWrappedError[T](rt: F[T])(h: PartialFunction[Throwable, F[T]]): F[T] = - F.recoverWith(rt)(h) -} |