aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKseniya Tomskikh <ktomskih@datamonsters.co>2018-04-09 13:42:15 +0700
committerKseniya Tomskikh <ktomskih@datamonsters.co>2018-04-09 13:42:15 +0700
commitdeaa879e7cf5157edd4616a650aa2511099bb375 (patch)
tree791e4138dd7eecffe6e2510566eb47db8be003af
parentad98b2237751adc7fcc1e9dfed437c8ff1f28f29 (diff)
downloaddriver-core-deaa879e7cf5157edd4616a650aa2511099bb375.tar.gz
driver-core-deaa879e7cf5157edd4616a650aa2511099bb375.tar.bz2
driver-core-deaa879e7cf5157edd4616a650aa2511099bb375.zip
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..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))