Last active
March 20, 2019 18:14
-
-
Save yasuabe/042bc28df9cb41cff165278492bc074d to your computer and use it in GitHub Desktop.
a simple example of hammock http client with Cats Effect IO and Apache HttpComponents Client
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
package qiita_sample1 | |
import cats.effect.{ExitCode, IO, IOApp} | |
import cats.free.Free | |
import hammock._ | |
import hammock.apache.ApacheInterpreter | |
object SimpleMain extends IOApp { | |
val program: Free[HttpF, HttpResponse] = Hammock | |
.request(Method.GET, uri"http://httpbin.org/get", Map()) | |
implicit val interpreter: InterpTrans[IO] = ApacheInterpreter[IO] | |
def run(args: List[String]): IO[ExitCode] = for { | |
res <- program.exec[IO] | |
_ <- IO(println(res.entity)) | |
} yield ExitCode.Success | |
} | |
// ---- build.sbt ---- | |
//name := "hammock_test" | |
// | |
//version := "0.1" | |
// | |
//scalaVersion := "2.12.8" | |
// | |
//val hammockVer = "0.9.0" | |
//val circeVer = "0.10.0" | |
// | |
//scalacOptions ++= Seq( | |
// "-encoding", "utf8", | |
// "-Xfatal-warnings", | |
// "-Ypartial-unification", | |
// "-deprecation", | |
// "-unchecked", | |
// "-language:implicitConversions", | |
// "-language:higherKinds", | |
// "-language:existentials", | |
// "-language:postfixOps" | |
//) | |
//libraryDependencies ++= Seq( | |
// "com.pepegar" %% "hammock-core", | |
// "com.pepegar" %% "hammock-circe", | |
// "com.pepegar" %% "hammock-apache-http", | |
// "com.pepegar" %% "hammock-asynchttpclient", | |
// "com.pepegar" %% "hammock-akka-http" | |
//).map(_ % hammockVer) ++ Seq( | |
// "io.circe" %% "circe-core", | |
// "io.circe" %% "circe-generic", | |
// "io.circe" %% "circe-parser" | |
//).map(_ % circeVer) ++ Seq( | |
// "io.monix" %% "monix" % "3.0.0-RC2", | |
// "io.frees" %% "iota-core" % "0.3.10" | |
//) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment