Last active
April 2, 2023 10:11
-
-
Save dacr/0062f55bf6b0dc07220e2e5431b4063c to your computer and use it in GitHub Desktop.
Simplest http4s http client library example / published by https://github.com/dacr/code-examples-manager #149bc5b3-7032-4f9e-9219-ce3942b9e78d/141c7265ca1ca6b8f7a13a21c167fd8d576d86df
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 : Simplest http4s http client library example | |
// keywords : scala, http4s, cats, 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 : 149bc5b3-7032-4f9e-9219-ce3942b9e78d | |
// created-on : 2022-01-08T14:25:51+01:00 | |
// managed-by : https://github.com/dacr/code-examples-manager | |
// run-with : scala-cli $file | |
// --------------------- | |
//> using scala "3.1.1" | |
//> using dep "org.http4s::http4s-dsl:1.0.0-M30" | |
//> using dep "org.http4s::http4s-blaze-server:1.0.0-M30" | |
//> using dep "org.http4s::http4s-blaze-client:1.0.0-M30" | |
// --------------------- | |
import cats.effect.* | |
import org.http4s.client.* | |
import org.http4s.implicits.* | |
object Hello extends IOApp.Simple: | |
def run = | |
val httpClient: Client[IO] = JavaNetClientBuilder[IO].create | |
for | |
response <- httpClient.expect[String](uri"https://mapland.fr/") | |
_ <- IO.println(response) | |
yield () | |
Hello.main(args) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment