Skip to content

Commit

Permalink
requests: more convenient API to customize the underlying HttpClient
Browse files Browse the repository at this point in the history
  • Loading branch information
fwbrasil committed Dec 11, 2023
1 parent d571497 commit ee3b812
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions kyo-sttp/jvm/src/main/scala/kyo/PlatformBackend.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,21 @@ package kyo

import kyo.requests.Backend
import sttp.client3._
import java.net.http.HttpClient
import kyo.internal.KyoSttpMonad
import sttp.capabilities.WebSockets

private[kyo] object PlatformBackend {

def apply(backend: SttpBackend[KyoSttpMonad.M, WebSockets]): Backend =
new Backend {
def send[T](r: Request[T, Any]) =
r.send(backend)
}

def apply(client: HttpClient): Backend =
apply(HttpClientKyoBackend.usingClient(client))

val default =
new Backend {
val b = HttpClientKyoBackend()
Expand Down

0 comments on commit ee3b812

Please sign in to comment.