aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKseniya Tomskikh <ktomskih@datamonsters.co>2018-04-10 11:59:05 +0700
committerGitHub <noreply@github.com>2018-04-10 11:59:05 +0700
commitb68e600258717bb6711e34aa427340ef304ef357 (patch)
treeca7daec81f346e11ff36bce3d90e698f2561d4a5
parent0231e921d110fe27ba8d51809620e7962a9eb867 (diff)
parent826b9f36405e8bf7fa24fb7c9c3852472560b26e (diff)
downloaddriver-core-b68e600258717bb6711e34aa427340ef304ef357.tar.gz
driver-core-b68e600258717bb6711e34aa427340ef304ef357.tar.bz2
driver-core-b68e600258717bb6711e34aa427340ef304ef357.zip
Merge pull request #150 from drivergroup/fix-patch-jsonv1.8.18
Created patch method for RestService with merge-patch+json media type
-rw-r--r--src/main/scala/xyz/driver/core/rest/RestService.scala6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/main/scala/xyz/driver/core/rest/RestService.scala b/src/main/scala/xyz/driver/core/rest/RestService.scala
index 2839c7e..8d46d72 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 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) =
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 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))