open source / oauth4s / http clients
HTTP clients
| Module | Client |
|---|---|
oauth4s-http-jdk |
java.net.http.HttpClient, part of the JDK |
oauth4s-http4s |
any org.http4s.client.Client[F] |
oauth4s-sttp |
any sttp client 4 Backend[F] |
scala
val jdk: HttpClient[IO] = JdkHttpClient[IO](timeout = 10.seconds)
def shared(client: JavaHttpClient): HttpClient[IO] = JdkHttpClient.from[IO](client) // one you configured: a proxy, an SSL context
def onHttp4s(client: Client[IO]): HttpClient[IO] = Http4sHttpClient(client) // ember, blaze, the JDK client — any http4s Client
def onSttp(backend: Backend[IO]): HttpClient[IO] = SttpHttpClient(backend) // any sttp client 4 backendHttpClient[F] is one method, so a client the library has no module for, or a wrapper around one it has, is short:
scala
final class Counted[F[*]](underlying: HttpClient[F], count: String => Unit)(using F: Effect[F]) extends HttpClient[F]:
def send(request: HttpRequest): F[HttpResponse] =
F.map(underlying.send(request)) { response =>
count(s"${request.method.name} ${response.status}") // never the body: it carries the secret
response
}The JDK client blocks a thread per request, inside Effect.blocking, which cats-effect and ZIO run on their blocking
pools. Use http4s or sttp where that matters.
built from README.md at v0.1.1
edit this page on GitHub