Created
October 16, 2012 22:36
-
-
Save Crash--/3902506 to your computer and use it in GitHub Desktop.
Rest method PUT not allowed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Zend 1.12 **/ | |
/** bootstrap / routes **/ | |
$front = \Zend_Controller_Front::getInstance(); | |
$front->setParam('bootstrap',$this); | |
//REST API | |
$router = $front->getRouter(); | |
$restRoute = new Zend_Rest_Route($front, array(), array( | |
'default' => array('rest'), | |
)); | |
$router->addRoute('rest', $restRoute); | |
/** restController **/ | |
<?php | |
//module : default | |
class RestController extends \Zend_Rest_Controller | |
public function init(){ | |
parent::init(); | |
$this->_helper->viewRenderer->setNoRender(true); | |
$this->_helper->layout->disableLayout(); | |
} | |
public function headAction(){} | |
public function indexAction() | |
{ | |
Throw new AppException(Translator::translate('index not yet implemented...')); | |
} | |
public function getAction() | |
{ | |
echo "get"; | |
} | |
public function putAction(){ | |
echo "put"; | |
} | |
/*** TestCase ***/ | |
curl -X GET http://XXXX/rest/MS4xMjU2LjEyNTguMTI2MS4tbW9kZWxzXGNvcmVcbW9kZWxcZXhlcmNpc2VcZXhlcmNpc2VfcXVlc3Rpb24tMTQy | |
get | |
==> OK | |
curl -X PUT http://XXXX/rest/MS4xMjU2LjEyNTguMTI2MS4tbW9kZWxzXGNvcmVcbW9kZWxcZXhlcmNpc2VcZXhlcmNpc2VfcXVlc3Rpb24tMTQy | |
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> | |
<html><head> | |
<title>405 Method Not Allowed</title> | |
</head><body> | |
<h1>Method Not Allowed</h1> | |
<p>The requested method PUT is not allowed for the URL /index.php.</p> | |
<hr> | |
<address>Apache/2.2.16 (Debian) Server at XXXXX Port 80</address> | |
</body></html> | |
/*** WHY ***/ | |
Why Apache gives me an error on the PUT Action? Why Apache says "index.php"? Why not /rest/index.php? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment