我有以下代码:
private def processRequest(
serviceName: String,
httpMethod: String,
request: HttpServiceResult[IncomingHttpRequest]
): Future[HttpResponse] =
request
.flatMap { incomingRequest =>
.. do something here ..
val responseDTO: Future[ResponseDTO] = database.getResponseByService(serviceName, httpMethod)
val httpResponse: Future[HttpResponse] = responseDTO
.map(
dto => HttpResponse(status = dto.responseCode, entity = dto.responsePayload)
)
EitherT.pure[Future, HttpError](httpResponse)
}
.fold(
error => {
logger.warn(
LoggingMessage(
requestId = error.requestId,
message = s"Error when processing request for inbound recon replay: ${error.message}"
)
)
HttpResponse(status = 200, entity = HttpEntity(s"err:${error.message}"))
},
identity
)
我猜想identity
代表了httpResponse,实际上是Future [HttpResponse],但是它只是一个HttpResponse,我该如何从Future [HttpResponse]中解开HttpResponse