Skip to content

Instantly share code, notes, and snippets.

@dcaoyuan
dcaoyuan / akka-http-client.scala
Created August 26, 2016 12:23
akka-http-client-example
val uri = "http://www.yahoo.com"
val reqEntity = Array[Byte]()
val respEntity = for {
request <- Marshal(reqEntity).to[RequestEntity]
response <- Http().singleRequest(HttpRequest(method = HttpMethods.POST, uri = uri, entity = request))
entity <- Unmarshal(response.entity).to[ByteString]
} yield entity
val payload = respEntity.andThen {