Skip to content

Instantly share code, notes, and snippets.

@dennypenta
Created March 11, 2020 08:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dennypenta/734e9db7f0930af028a5b28688957b47 to your computer and use it in GitHub Desktop.
Save dennypenta/734e9db7f0930af028a5b28688957b47 to your computer and use it in GitHub Desktop.
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