Skip to content

Commit

Permalink
Make client middleware cancellable
Browse files Browse the repository at this point in the history
  • Loading branch information
msosnicki committed Jun 5, 2023
1 parent 300082d commit dd72ceb
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ object NatchezMiddleware {
implicit ev: MonadCancel[F, Throwable]
): Client[F] =
Client { req =>
Resource {
Resource.applyFull {poll =>
Trace[F].span("http4s-client-request") {
for {
knl <- Trace[F].kernel
Expand All @@ -106,7 +106,7 @@ object NatchezMiddleware {
"client.http.method" -> req.method.toString
)
reqʹ = req.withHeaders(knl.toHttp4sHeaders ++ req.headers) // prioritize request headers over kernel ones
rsrc <- client.run(reqʹ).allocated
rsrc <- poll(client.run(reqʹ).allocatedCase)
_ <- Trace[F].put("client.http.status_code" -> rsrc._1.status.code.toString())
} yield rsrc
}
Expand Down

0 comments on commit dd72ceb

Please sign in to comment.