Skip to content

Instantly share code, notes, and snippets.

@dacr
Last active May 7, 2023 07:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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/8717113d388bf8cafa5d34a1aedaac16233cb5fd
// 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.2.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