Created
May 20, 2015 18:00
-
-
Save mrbrdo/eb362e512d75adfbea82 to your computer and use it in GitHub Desktop.
This file contains 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
val connection = Http(context.system).outgoingConnection("localhost", 8008) | |
val request = | |
RequestBuilding.Get("/repos/mrbrdo/test_repo/pulls") | |
.withHeaders( | |
RawHeader("Accept", "application/vnd.github.v3+json")) | |
async[Unit] { | |
val response = await(Source.single(request).via(connection).runWith(Sink.head)) | |
response.status match { | |
case status if status.isSuccess() => | |
val result = await(response.entity.getDataBytes().runFold[ByteString](ByteString()) { (a, e) => | |
a ++ e | |
}) | |
println(result.decodeString("utf-8")) | |
println("success") | |
case _ => | |
println("failure") | |
} | |
}.onFailure { case (exception) => | |
println("Failure:") | |
exception.printStackTrace() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment