Skip to content

Instantly share code, notes, and snippets.

@mrbrdo
Created May 20, 2015 18:00
Show Gist options
  • Save mrbrdo/eb362e512d75adfbea82 to your computer and use it in GitHub Desktop.
Save mrbrdo/eb362e512d75adfbea82 to your computer and use it in GitHub Desktop.
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