Last active
February 3, 2026 20:25
-
-
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/65f51be75076be9ed57c1ddde6965729b1d46df6
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 License Version 2.0 (https://www.apache.org/licenses/LICENSE-2.0.txt) | |
| // 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