Last active
May 7, 2023 07:13
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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