Skip to content

Instantly share code, notes, and snippets.

@takezoe
Created June 19, 2016 16:35
Show Gist options
  • Save takezoe/b758434f6816f56aab4d9d00489826ea to your computer and use it in GitHub Desktop.
Save takezoe/b758434f6816f56aab4d9d00489826ea to your computer and use it in GitHub Desktop.
import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.model._
import akka.http.scaladsl.unmarshalling.Unmarshal
import akka.stream.ActorMaterializer
import scala.concurrent.ExecutionContext.Implicits.global
object AkkaHttpSample extends App {
implicit val system = ActorSystem()
implicit val materializer = ActorMaterializer()
val f = Http().singleRequest(HttpRequest(uri = "https://jp.stanby.com/"))
f.foreach { res =>
Unmarshal(res.entity).to[String].foreach { s =>
println(s)
system.terminate()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment