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.
This commit is contained in:
Bharat Mediratta
2010-07-16 14:23:03 -07:00
parent ed704e6a3b
commit 71a32e4e24
+5
View File
@@ -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