Skip to content

Instantly share code, notes, and snippets.

@dacr
Last active May 25, 2024 10:18
Show Gist options
  • Save dacr/8f43b8c62207fc532092d38bf6d2cdb4 to your computer and use it in GitHub Desktop.
Save dacr/8f43b8c62207fc532092d38bf6d2cdb4 to your computer and use it in GitHub Desktop.
ZIO learning - zhttp - simplest http client / published by https://github.com/dacr/code-examples-manager #6a32e396-78a2-4ed7-bef3-3f1a0e33b4c1/b4d1d0356f526bdeda8b44f98b51537bb58cf851
// summary : ZIO learning - zhttp - simplest http client
// keywords : scala, zio, learning, pure-functional, zhttp, http-client, @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 : 6a32e396-78a2-4ed7-bef3-3f1a0e33b4c1
// 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-http:3.0.0-RC1"
//> using dep "fr.janalyse::zio-worksheet:2.0.13.0"
// ---------------------
import zio.*, zio.worksheet.*, zio.http.*
val logic = for {
response <- Client.request("http://httpbin.org/get")
content <- response.body.asString
_ <- Console.printLine(content)
} yield ()
logic.provide(Client.default).unsafeRun
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment