Skip to content

Commit

Permalink
Add HttpClientFs2Backend.resourceUsingClient.
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilkloch committed Nov 8, 2022
1 parent edc6f4d commit 618b130
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,17 @@ object HttpClientFs2Backend {
Resource.make(apply(dispatcher, options, customizeRequest, customEncodingHandler))(_.close())
)

def resourceUsingClient[F[_]: Async](
client: HttpClient,
customizeRequest: HttpRequest => HttpRequest = identity,
customEncodingHandler: Fs2EncodingHandler[F] = PartialFunction.empty
): Resource[F, SttpBackend[F, Fs2Streams[F] with WebSockets]] =
Dispatcher[F].flatMap(dispatcher =>
Resource.make(
Sync[F].delay(apply(client, closeClient = true, customizeRequest, customEncodingHandler, dispatcher))
)(_.close())
)

def usingClient[F[_]: Async](
client: HttpClient,
dispatcher: Dispatcher[F],
Expand Down

0 comments on commit 618b130

Please sign in to comment.