diff options
author | adamw <adam@warski.org> | 2017-09-04 16:27:43 +0200 |
---|---|---|
committer | adamw <adam@warski.org> | 2017-09-04 16:27:43 +0200 |
commit | 2761923dcf1ea49f7671cc2f18df9bd07f0df40b (patch) | |
tree | 1e20c4d823f0ff734d77c54e96ab738f4186c740 /async-http-client-handler/fs2/src/main | |
parent | 41bbe08c125bb3714aee862ec9dc55419c29986d (diff) | |
download | sttp-2761923dcf1ea49f7671cc2f18df9bd07f0df40b.tar.gz sttp-2761923dcf1ea49f7671cc2f18df9bd07f0df40b.tar.bz2 sttp-2761923dcf1ea49f7671cc2f18df9bd07f0df40b.zip |
Extracting FollowRedirectsHandler as a wrapper-handler
Diffstat (limited to 'async-http-client-handler/fs2/src/main')
-rw-r--r-- | async-http-client-handler/fs2/src/main/scala/com/softwaremill/sttp/asynchttpclient/fs2/AsyncHttpClientFs2Handler.scala | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/async-http-client-handler/fs2/src/main/scala/com/softwaremill/sttp/asynchttpclient/fs2/AsyncHttpClientFs2Handler.scala b/async-http-client-handler/fs2/src/main/scala/com/softwaremill/sttp/asynchttpclient/fs2/AsyncHttpClientFs2Handler.scala index 1686b25..56e7b8c 100644 --- a/async-http-client-handler/fs2/src/main/scala/com/softwaremill/sttp/asynchttpclient/fs2/AsyncHttpClientFs2Handler.scala +++ b/async-http-client-handler/fs2/src/main/scala/com/softwaremill/sttp/asynchttpclient/fs2/AsyncHttpClientFs2Handler.scala @@ -5,6 +5,7 @@ import java.nio.ByteBuffer import cats.effect._ import com.softwaremill.sttp.asynchttpclient.AsyncHttpClientHandler import com.softwaremill.sttp.{ + FollowRedirectsHandler, MonadAsyncError, SttpHandler, Utf8, @@ -51,6 +52,12 @@ class AsyncHttpClientFs2Handler[F[_]: Effect] private ( object AsyncHttpClientFs2Handler { + private def apply[F[_]: Effect](asyncHttpClient: AsyncHttpClient, + closeClient: Boolean)( + implicit ec: ExecutionContext): SttpHandler[F, Stream[F, ByteBuffer]] = + new FollowRedirectsHandler( + new AsyncHttpClientFs2Handler(asyncHttpClient, closeClient)) + /** * @param ec The execution context for running non-network related operations, * e.g. mapping responses. Defaults to the global execution @@ -59,8 +66,8 @@ object AsyncHttpClientFs2Handler { def apply[F[_]: Effect]()( implicit ec: ExecutionContext = ExecutionContext.Implicits.global) : SttpHandler[F, Stream[F, ByteBuffer]] = - new AsyncHttpClientFs2Handler[F](new DefaultAsyncHttpClient(), - closeClient = true) + AsyncHttpClientFs2Handler[F](new DefaultAsyncHttpClient(), + closeClient = true) /** * @param ec The execution context for running non-network related operations, @@ -70,8 +77,8 @@ object AsyncHttpClientFs2Handler { def usingConfig[F[_]: Effect](cfg: AsyncHttpClientConfig)( implicit ec: ExecutionContext = ExecutionContext.Implicits.global) : SttpHandler[F, Stream[F, ByteBuffer]] = - new AsyncHttpClientFs2Handler[F](new DefaultAsyncHttpClient(cfg), - closeClient = true) + AsyncHttpClientFs2Handler[F](new DefaultAsyncHttpClient(cfg), + closeClient = true) /** * @param ec The execution context for running non-network related operations, @@ -81,7 +88,7 @@ object AsyncHttpClientFs2Handler { def usingClient[F[_]: Effect](client: AsyncHttpClient)( implicit ec: ExecutionContext = ExecutionContext.Implicits.global) : SttpHandler[F, Stream[F, ByteBuffer]] = - new AsyncHttpClientFs2Handler[F](client, closeClient = false) + AsyncHttpClientFs2Handler[F](client, closeClient = false) } private[fs2] class EffectMonad[F[_]](implicit F: Effect[F]) |