Response without unmarshalling

Hello, i would like to send back an entity as response without unmashalling, ie the response of my endpoint should be the response of a call to an external service. Something like:

get {
    Http()
      .singleRequest(
        request = HttpRequest(
          method = HttpMethods.GET,
          uri    = s"http://localhost:8090/data",
        )
      )
      .flatMap {
        case HttpResponse(StatusCodes.OK, _, entity, _) =>
          Future.successful(entity)
        case HttpResponse(status, _, entity, _) =>
          log.error(s"Unable to fetch external service data, status: $status")
          entity
            .discardBytes()
            .future()
            .flatMap(_ => Future.failed(new IllegalStateException(s"status: $status")))
      }

Is it even possible to send back some non unmarshaled data ?

1 Like