Created
March 11, 2020 08:59
-
-
Save dennypenta/734e9db7f0930af028a5b28688957b47 to your computer and use it in GitHub Desktop.
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 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