Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement cats-effect native backend #2035

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package sttp.client4.impl.cats

import cats.effect.kernel.Sync
import sttp.client4._
import sttp.client4.curl.internal.CurlApi._
import sttp.client4.curl.AbstractCurlBackend
import sttp.client4.curl.internal.CurlCode.CurlCode
import sttp.client4.wrappers.FollowRedirectsBackend
import sttp.client4.testing.BackendStub

class CurlCatsBackend[F[_]: Sync] private (
verbose: Boolean
) extends AbstractCurlBackend[F](new CatsMonadError, verbose)
with Backend[F] {

override def performCurl(c: CurlHandle): F[CurlCode] = Sync[F].blocking(c.perform)

}

object CurlCatsBackend {
def apply[F[_]: Sync](verbose: Boolean = false): Backend[F] =
FollowRedirectsBackend(new CurlCatsBackend[F](verbose))

def stub[F[_]: Sync]: BackendStub[F] = BackendStub(new CatsMonadError)

}