Last active
June 15, 2024 07:58
-
-
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/d1faee7faa9f40df42acc949aed8e2ae7ff2c900
This file contains hidden or 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.4.2" | |
//> using dep "org.http4s::http4s-dsl:0.23.27" | |
//> using dep "org.http4s::http4s-blaze-server:0.23.16" | |
//> using dep "org.http4s::http4s-blaze-client:0.23.16" | |
// --------------------- | |
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