From ff05b82d3a08a586febb9b8ac090fafb34f67250 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sat, 18 Nov 2017 21:51:56 -0500 Subject: [PATCH] RestAction: Support OPTIONS and fix old StopWithCode. --- http/rest_action.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/http/rest_action.php b/http/rest_action.php index b3d2c5d..ca6e870 100644 --- a/http/rest_action.php +++ b/http/rest_action.php @@ -30,11 +30,10 @@ class RestAction extends Action */ public function Invoke(Request $request, Response $response) { - $valid_methods = array('get', 'post', 'delete', 'put'); + $valid_methods = array('options', 'get', 'post', 'delete', 'put'); $method = strtolower($request->http_method); if (!in_array($method, $valid_methods)) { - $response->response_code = ResponseCode::METHOD_NOT_ALLOWED; - $this->controller()->Stop(); + $this->controller()->SendResponseCode(ResponseCode::METHOD_NOT_ALLOWED); return; } @@ -43,23 +42,27 @@ class RestAction extends Action } /*! Methods for each of the different HTTP methods. */ + + + public function DoOptions(Request $request, Response $response) {} + public function DoGet(Request $request, Response $response) { - $this->controller()->StopWithCode(ResponseCode::METHOD_NOT_ALLOWED); + $this->controller()->SendReseponseCode(ResponseCode::METHOD_NOT_ALLOWED); } public function DoPost(Request $request, Response $response) { - $this->controller()->StopWithCode(ResponseCode::METHOD_NOT_ALLOWED); + $this->controller()->SendReseponseCode(ResponseCode::METHOD_NOT_ALLOWED); } public function DoDelete(Request $request, Response $response) { - $this->controller()->StopWithCode(ResponseCode::METHOD_NOT_ALLOWED); + $this->controller()->SendReseponseCode(ResponseCode::METHOD_NOT_ALLOWED); } public function DoPut(Request $request, Response $response) { - $this->controller()->StopWithCode(ResponseCode::METHOD_NOT_ALLOWED); + $this->controller()->SendReseponseCode(ResponseCode::METHOD_NOT_ALLOWED); } } -- 2.22.5