diff options
author | kseniya <ktomskih@datamonsters.co> | 2017-09-20 18:01:15 +0700 |
---|---|---|
committer | kseniya <ktomskih@datamonsters.co> | 2017-09-20 18:01:15 +0700 |
commit | 9968eaefa2a97ebe495fa51b640e31c78db61ac6 (patch) | |
tree | 4eed12a4ebb2829e336a3da673c7c8462e7ab845 /src/main/scala/xyz/driver/pdsuidomain/services/rest | |
parent | d5ecec043a3d70dd09bda8a79fcd188f411b47df (diff) | |
parent | d4b18efda238f506103dddbf3b400ae17c797276 (diff) | |
download | rest-query-9968eaefa2a97ebe495fa51b640e31c78db61ac6.tar.gz rest-query-9968eaefa2a97ebe495fa51b640e31c78db61ac6.tar.bz2 rest-query-9968eaefa2a97ebe495fa51b640e31c78db61ac6.zip |
Merge branch 'master' into slick-query-builder
Diffstat (limited to 'src/main/scala/xyz/driver/pdsuidomain/services/rest')
-rw-r--r-- | src/main/scala/xyz/driver/pdsuidomain/services/rest/RestTrialService.scala | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/main/scala/xyz/driver/pdsuidomain/services/rest/RestTrialService.scala b/src/main/scala/xyz/driver/pdsuidomain/services/rest/RestTrialService.scala index 9f72760..f826b98 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/services/rest/RestTrialService.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/services/rest/RestTrialService.scala @@ -1,6 +1,9 @@ package xyz.driver.pdsuidomain.services.rest import scala.concurrent.{ExecutionContext, Future} +import akka.NotUsed +import akka.stream.scaladsl.Source +import akka.util.ByteString import akka.http.scaladsl.marshalling.Marshal import akka.http.scaladsl.model._ import akka.stream.Materializer @@ -43,8 +46,15 @@ class RestTrialService(transport: ServiceTransport, baseUri: Uri)(implicit prote } def getPdfSource(trialId: StringId[Trial])( - implicit requestContext: AuthenticatedRequestContext): Future[GetPdfSourceReply] = - Future.failed(new NotImplementedError("Streaming PDF over network is not supported.")) + implicit requestContext: AuthenticatedRequestContext): Future[Source[ByteString, NotUsed]] = { + val request = HttpRequest(HttpMethods.GET, endpointUri(baseUri, s"/v1/trial/${trialId}/source")) + for { + response <- transport.sendRequestGetResponse(requestContext)(request) + reply <- apiResponse[HttpEntity](response) + } yield { + reply.dataBytes.mapMaterializedValue(_ => NotUsed) + } + } def getAll(filter: SearchFilterExpr = SearchFilterExpr.Empty, sorting: Option[Sorting] = None, |