Skip to content

Commit 63194e1

Browse files
committed
Merge pull request #31 from mfn/basic-patch-support
Pave path to technically allow PATCH requests
2 parents ceca41f + 02ce42b commit 63194e1

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/EchoIt/JsonApi/Handler.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ public static function successfulHttpStatusCode($method, $model = null)
277277
// if we did a put request, we need to ensure that the model wasn't
278278
// changed in other ways than those specified by the request
279279
// Ref: http://jsonapi.org/format/#crud-updating-responses-200
280-
if ($method === 'PUT' && $model instanceof Model) {
280+
if (($method === 'PATCH' || $method === 'PUT') && $model instanceof Model) {
281281
// check if the model has been changed
282282
if ($model->isChanged()) {
283283
// return our response as if there was a GET request
@@ -288,6 +288,7 @@ public static function successfulHttpStatusCode($method, $model = null)
288288
switch ($method) {
289289
case 'POST':
290290
return BaseResponse::HTTP_CREATED;
291+
case 'PATCH':
291292
case 'PUT':
292293
case 'DELETE':
293294
return BaseResponse::HTTP_NO_CONTENT;
@@ -296,7 +297,7 @@ public static function successfulHttpStatusCode($method, $model = null)
296297
}
297298

298299
// Code shouldn't reach this point, but if it does we assume that the
299-
// client has made a bad request, e.g. PATCH
300+
// client has made a bad request.
300301
return BaseResponse::HTTP_BAD_REQUEST;
301302
}
302303

0 commit comments

Comments
 (0)