From deaa879e7cf5157edd4616a650aa2511099bb375 Mon Sep 17 00:00:00 2001 From: Kseniya Tomskikh Date: Mon, 9 Apr 2018 13:42:15 +0700 Subject: Created patch method for RestService with merge-patch+json media type --- src/main/scala/xyz/driver/core/rest/RestService.scala | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/scala/xyz/driver/core/rest/RestService.scala b/src/main/scala/xyz/driver/core/rest/RestService.scala index 2839c7e..bd977aa 100644 --- a/src/main/scala/xyz/driver/core/rest/RestService.scala +++ b/src/main/scala/xyz/driver/core/rest/RestService.scala @@ -34,6 +34,9 @@ trait RestService extends Service { protected def jsonEntity(json: JsValue): RequestEntity = HttpEntity(ContentTypes.`application/json`, json.compactPrint) + protected def patchableJsonEntity(json: JsValue): RequestEntity = + HttpEntity(PatchDirectives.`application/merge-patch+json`, json.compactPrint) + protected def get(baseUri: Uri, path: String, query: Seq[(String, String)] = Seq.empty) = HttpRequest(HttpMethods.GET, endpointUri(baseUri, path, query)) @@ -55,6 +58,9 @@ trait RestService extends Service { protected def patchJson(baseUri: Uri, path: String, json: JsValue) = HttpRequest(HttpMethods.PATCH, endpointUri(baseUri, path), entity = jsonEntity(json)) + protected def patchableJson(baseUri: Uri, path: String, json: JsValue) = + HttpRequest(HttpMethods.PATCH, endpointUri(baseUri, path), entity = patchableJsonEntity(json)) + protected def delete(baseUri: Uri, path: String, query: Seq[(String, String)] = Seq.empty) = HttpRequest(HttpMethods.DELETE, endpointUri(baseUri, path, query)) -- cgit v1.2.3 From 826b9f36405e8bf7fa24fb7c9c3852472560b26e Mon Sep 17 00:00:00 2001 From: Kseniya Tomskikh Date: Tue, 10 Apr 2018 11:45:14 +0700 Subject: Review fix --- src/main/scala/xyz/driver/core/rest/RestService.scala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/scala/xyz/driver/core/rest/RestService.scala b/src/main/scala/xyz/driver/core/rest/RestService.scala index bd977aa..8d46d72 100644 --- a/src/main/scala/xyz/driver/core/rest/RestService.scala +++ b/src/main/scala/xyz/driver/core/rest/RestService.scala @@ -34,7 +34,7 @@ trait RestService extends Service { protected def jsonEntity(json: JsValue): RequestEntity = HttpEntity(ContentTypes.`application/json`, json.compactPrint) - protected def patchableJsonEntity(json: JsValue): RequestEntity = + protected def mergePatchJsonEntity(json: JsValue): RequestEntity = HttpEntity(PatchDirectives.`application/merge-patch+json`, json.compactPrint) protected def get(baseUri: Uri, path: String, query: Seq[(String, String)] = Seq.empty) = @@ -58,8 +58,8 @@ trait RestService extends Service { protected def patchJson(baseUri: Uri, path: String, json: JsValue) = HttpRequest(HttpMethods.PATCH, endpointUri(baseUri, path), entity = jsonEntity(json)) - protected def patchableJson(baseUri: Uri, path: String, json: JsValue) = - HttpRequest(HttpMethods.PATCH, endpointUri(baseUri, path), entity = patchableJsonEntity(json)) + protected def mergePatchJson(baseUri: Uri, path: String, json: JsValue) = + HttpRequest(HttpMethods.PATCH, endpointUri(baseUri, path), entity = mergePatchJsonEntity(json)) protected def delete(baseUri: Uri, path: String, query: Seq[(String, String)] = Seq.empty) = HttpRequest(HttpMethods.DELETE, endpointUri(baseUri, path, query)) -- cgit v1.2.3