summaryrefslogtreecommitdiff
path: root/modules/rest/controllers
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2010-07-16 14:23:03 -0700
committerBharat Mediratta <bharat@menalto.com>2010-07-16 14:23:03 -0700
commit71a32e4e2453b8e6dec922e88180960a3a5b9aec (patch)
treef76889fc993a2644e11b61a055b3b4e8daf80d7d /modules/rest/controllers
parented704e6a3bcd24c9d0ffbc4e71d2441aba4e9d0b (diff)
POST requests create a new entity and should result in a 201 Created
reply with a Location field that matches the URL of the newly created resource. Fixes ticket #1178.
Diffstat (limited to 'modules/rest/controllers')
-rw-r--r--modules/rest/controllers/rest.php5
1 files changed, 5 insertions, 0 deletions
diff --git a/modules/rest/controllers/rest.php b/modules/rest/controllers/rest.php
index 293252ef..bf2f0a54 100644
--- a/modules/rest/controllers/rest.php
+++ b/modules/rest/controllers/rest.php
@@ -81,6 +81,11 @@ class Rest_Controller extends Controller {
}
$response = call_user_func(array($handler_class, $handler_method), $request);
+ if ($handler_method == "post") {
+ // post methods must return a response containing a URI.
+ header("HTTP/1.1 201 Created");
+ header("Location: {$response['url']}");
+ }
rest::reply($response);
} catch (ORM_Validation_Exception $e) {
// Note: this is totally insufficient because it doesn't take into account localization. We