Skip to content

Instantly share code, notes, and snippets.

@dcaoyuan
dcaoyuan / akka-http-client.scala
Created Aug 26, 2016
akka-http-client-example
View akka-http-client.scala
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 {