Skip to content

Instantly share code, notes, and snippets.

@dacr
Last active June 15, 2024 07:58
Show Gist options
  • Save dacr/0062f55bf6b0dc07220e2e5431b4063c to your computer and use it in GitHub Desktop.
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
// 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