Skip to content

Instantly share code, notes, and snippets.

@dacr
Last active October 8, 2023 08:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dacr/d192dc52564fbf75c63da2ea81453a23 to your computer and use it in GitHub Desktop.
Save dacr/d192dc52564fbf75c63da2ea81453a23 to your computer and use it in GitHub Desktop.
ZIO learning - Simplest http client using sttp / published by https://github.com/dacr/code-examples-manager #7c34fd86-2780-4a3b-9b7b-99f20c2bf9b0/1e674d956c254c1540210dfb01428e6e335a22b3
// summary : ZIO learning - Simplest http client using sttp
// keywords : scala, zio, learning, pure-functional, sttp, @testable
// publish : gist
// authors : David Crosson
// license : Apache NON-AI License Version 2.0 (https://raw.githubusercontent.com/non-ai-licenses/non-ai-licenses/main/NON-AI-APACHE2)
// id : 7c34fd86-2780-4a3b-9b7b-99f20c2bf9b0
// created-on : 2022-07-18T14:40:23+02:00
// managed-by : https://github.com/dacr/code-examples-manager
// run-with : scala-cli $file
// ---------------------
//> using scala "3.3.1"
//> 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()
result <- backend.send(quickRequest.get(uri"https://mapland.fr/ip"))
_ <- Console.printLine(result.body)
} yield ()
logic.unsafeRun
@dbuschman7
Copy link

Scala-cli !!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment