Suppose we have the following request:
curl --location --request POST 'localhost:8080/api' \
--header 'Content-Type: multipart/form-data' \
--form 'field1=value1' \
--form 'field2=value2'
The request handler below gets the whole entity, but I am struggling to see how I could instead get value1 and value2.
val requestHandler: Flow[HttpRequest, HttpResponse, _] = Flow[HttpRequest].mapAsync(1) {
  case HttpRequest(HttpMethods.POST, Uri.Path("/api"), _, entity, _) =>
    val entityTextFuture: Future[String] = entity.toStrict(3 seconds).map(_.data.utf8String)
      entityTextFuture.flatMap { text =>
        Future(HttpResponse(
          StatusCodes.OK,
          entity = text
        ))
      }
}
Important: I have to use the Akka HTTP low-level server API, so I cannot use routes.
Many thanks for your time and help in advance!
 
    