The default behavior for RestAction should be to error METHOD_NOT_ALLOWED.
authorRobert Sesek <rsesek@bluestatic.org>
Mon, 25 May 2015 21:12:52 +0000 (17:12 -0400)
committerRobert Sesek <rsesek@bluestatic.org>
Mon, 25 May 2015 21:12:52 +0000 (17:12 -0400)
http/rest_action.php
testing/tests/http/fixtures.php

index 35c5191848baf6060f196270954fc9af482df5f0..b3d2c5dd8fd6ddfe545ca5d48138ff89a9527e67 100644 (file)
@@ -1,11 +1,11 @@
 <?php
 // Hoplite
 // Copyright (c) 2011 Blue Static
-// 
+//
 // This program is free software: you can redistribute it and/or modify it
 // under the terms of the GNU General Public License as published by the Free
 // Software Foundation, either version 3 of the License, or any later version.
-// 
+//
 // This program is distributed in the hope that it will be useful, but WITHOUT
 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
@@ -43,8 +43,23 @@ class RestAction extends Action
   }
 
   /*! Methods for each of the different HTTP methods. */
-  public function DoGet(Request $request, Response $response) {}
-  public function DoPost(Request $request, Response $response) {}
-  public function DoDelete(Request $request, Response $response) {}
-  public function DoPut(Request $request, Response $response) {}
+  public function DoGet(Request $request, Response $response)
+  {
+    $this->controller()->StopWithCode(ResponseCode::METHOD_NOT_ALLOWED);
+  }
+
+  public function DoPost(Request $request, Response $response)
+  {
+    $this->controller()->StopWithCode(ResponseCode::METHOD_NOT_ALLOWED);
+  }
+
+  public function DoDelete(Request $request, Response $response)
+  {
+    $this->controller()->StopWithCode(ResponseCode::METHOD_NOT_ALLOWED);
+  }
+
+  public function DoPut(Request $request, Response $response)
+  {
+    $this->controller()->StopWithCode(ResponseCode::METHOD_NOT_ALLOWED);
+  }
 }
index fcd30826e06fe293a1a825decbdda229f63b3dab..20dff3191eac3cc342f453a97ef587341fd55ec9 100644 (file)
@@ -26,22 +26,18 @@ class TestRestAction extends \hoplite\http\RestAction
 
   public function DoGet(http\Request $request, http\Response $response)
   {
-    parent::DoGet($request, $response);
     $this->did_get = TRUE;
   }
   public function DoPost(http\Request $request, http\Response $response)
   {
-    parent::DoPost($request, $response);
     $this->did_post = TRUE;
   }
   public function DoDelete(http\Request $request, http\Response $response)
   {
-    parent::DoDelete($request, $response);
     $this->did_delete = TRUE;
   }
   public function DoPut(http\Request $request, http\Response $response)
   {
-    parent::DoPut($request, $response);
     $this->did_put = TRUE;
   }
 }