Skip to content

Instantly share code, notes, and snippets.

@dacr
Last active February 3, 2026 20:24
Show Gist options
  • Select an option

  • Save dacr/d82350ff33b06c1e84ff1e3128dc560c to your computer and use it in GitHub Desktop.

Select an option

Save dacr/d82350ff33b06c1e84ff1e3128dc560c to your computer and use it in GitHub Desktop.
ZIO learning - scoped http client / published by https://github.com/dacr/code-examples-manager #c8bbf699-e503-4c78-b7ca-6252780133fe/92daade35091ebcd514880a56e6486961dc297bc
// summary : ZIO learning - scoped http client
// keywords : scala, zio, learning, pure-functional, sttp, @testable
// publish : gist
// authors : David Crosson
// license : Apache License Version 2.0 (https://www.apache.org/licenses/LICENSE-2.0.txt)
// id : c8bbf699-e503-4c78-b7ca-6252780133fe
// created-on : 2021-04-04T17:33:20Z
// managed-by : https://github.com/dacr/code-examples-manager
// run-with : scala-cli $file
// ---------------------
//> using scala "3.4.2"
//> using dep "dev.zio::zio:2.0.13"
//> using dep "fr.janalyse::zio-worksheet:2.0.13.0"
//> using dep "com.softwaremill.sttp.client4::zio:4.0.0-M5"
// ---------------------
import zio.*, zio.worksheet.*
import sttp.client4.*, sttp.client4.basicRequest.*
import sttp.client4.httpclient.zio.HttpClientZioBackend
val logic = for {
backend <- HttpClientZioBackend.scoped()
result <- backend.send(quickRequest.get(uri"https://mapland.fr/ip"))
_ <- Console.printLine(result.body)
} yield ()
ZIO.scoped(logic).unsafeRun
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment