aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/xyz/driver/pdsuidomain/services/rest/RestHelper.scala
diff options
context:
space:
mode:
authorJakob Odersky <jakob@driver.xyz>2017-07-13 02:06:27 -0700
committerJakob Odersky <jakob@driver.xyz>2017-07-13 02:06:27 -0700
commite5fe8c9a46426ff19757b37a8bcb2b3f51fc2701 (patch)
treedae9196690d5bfdc15f253677e5c41461fbefb0b /src/main/scala/xyz/driver/pdsuidomain/services/rest/RestHelper.scala
parent3e700be0b7df8022627b1f46890f3e3dad3fa54b (diff)
downloadrest-query-e5fe8c9a46426ff19757b37a8bcb2b3f51fc2701.tar.gz
rest-query-e5fe8c9a46426ff19757b37a8bcb2b3f51fc2701.tar.bz2
rest-query-e5fe8c9a46426ff19757b37a8bcb2b3f51fc2701.zip
Refactor reply mapping
Diffstat (limited to 'src/main/scala/xyz/driver/pdsuidomain/services/rest/RestHelper.scala')
-rw-r--r--src/main/scala/xyz/driver/pdsuidomain/services/rest/RestHelper.scala10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/main/scala/xyz/driver/pdsuidomain/services/rest/RestHelper.scala b/src/main/scala/xyz/driver/pdsuidomain/services/rest/RestHelper.scala
index bd9580a..3113b21 100644
--- a/src/main/scala/xyz/driver/pdsuidomain/services/rest/RestHelper.scala
+++ b/src/main/scala/xyz/driver/pdsuidomain/services/rest/RestHelper.scala
@@ -15,7 +15,6 @@ import xyz.driver.pdsuicommon.db.{
Sorting,
SortingOrder
}
-import xyz.driver.pdsuicommon.serialization.PlayJsonSupport
import xyz.driver.pdsuicommon.error._
trait RestHelper {
@@ -92,11 +91,11 @@ trait RestHelper {
* is not explicitly handled, it will be encoded as a failure in the returned future.
* @param unmarshaller An unmarshaller that converts a successful response to an api reply.
*/
- def apiResponse[ApiReply, DomainReply](response: HttpResponse)(successMapper: ApiReply => DomainReply)(
- implicit unmarshaller: Unmarshaller[ResponseEntity, ApiReply]): Future[DomainReply] = {
+ def apiResponse[ApiReply](response: HttpResponse)(
+ implicit unmarshaller: Unmarshaller[ResponseEntity, ApiReply]): Future[ApiReply] = {
def extractErrorMessage(response: HttpResponse): Future[String] = {
- import PlayJsonSupport._
+ import xyz.driver.pdsuicommon.serialization.PlayJsonSupport._
Unmarshal(response.entity)
.to[ErrorsResponse.ResponseError]
.transform(
@@ -106,8 +105,7 @@ trait RestHelper {
}
if (response.status.isSuccess) {
- val reply = Unmarshal(response.entity).to[ApiReply]
- reply.map(successMapper)
+ Unmarshal(response.entity).to[ApiReply]
} else {
extractErrorMessage(response).flatMap { message =>
Future.failed(response.status match {