akka HttpResponse read body as String scala

前端 未结 7 983
广开言路
广开言路 2020-12-28 13:27

So I have a function with this signature (akka.http.model.HttpResponse):

def apply(query: Seq[(String, String)], accept: String): HttpResponse
7条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-28 14:03

    import akka.http.scaladsl.unmarshalling.Unmarshal
    
    implicit val system = ActorSystem("System")  
    implicit val materializer = ActorFlowMaterializer() 
    
    val responseAsString: Future[String] = Unmarshal(entity).to[String]
    

提交回复
热议问题