Skip to content

Instantly share code, notes, and snippets.

@dennypenta

dennypenta/app.scala

Created Mar 11, 2020
Embed
What would you like to do?
package com.dennypenta.meme_keker
import akka.actor.ActorSystem
import akka.stream.ActorMaterializer
import akka.http.scaladsl.Http
import akka.http.scaladsl.model.HttpRequest
import akka.http.scaladsl.model.HttpResponse
import scala.concurrent.Future
import scala.util.{Failure, Success}
object MemeKeker extends App {
implicit val system = ActorSystem()
implicit val materializer = ActorMaterializer()
// needed for the future flatMap/onComplete in the end
implicit val executionContext = system.dispatcher
val req = HttpRequest(uri = "https://akka.io")
val future: Future[HttpResponse] = Http().singleRequest(req)
future.onComplete {
case Success(res) => println(res)
case Failure(_) => sys.error("request failed")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment