akka HttpResponse read body as String scala

前端 未结 7 984
广开言路
广开言路 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

    Here is simple directive that extracts string from request's body

    def withString(): Directive1[String] = {
      extractStrictEntity(3.seconds).flatMap { entity =>
        provide(entity.data.utf8String)
      }
    }
    

提交回复
热议问题