具有主干、DELETE 和 PUT 请求的 CodeIgniter Rest Server 返回 404


CodeIgniter Rest Server with Backbone, DELETE and PUT requests return 404

我正在使用骨干和CodeIgniter Rest Server,帖子和从骨干网获取请求工作正常但是放置和删除请求者收到 404 错误,响应为 {"status":false,"error":"未知方法。

编辑:我更改了源代码以查看代码点火器尝试运行的方法我的控制器网址是

http://local/host/impacto/index.php/interviews/

放置请求 URL 是

http://localhost/impacto/index.php/interviews/13

并且 codeigniter 正在运行的功能是13_put而不是input_put

我的控制器

class Interview extends REST_Controller {
function __construct(){
    parent:: __construct();
}
public function index_get(){
    echo "get";
}
public function index_post(){
    echo "post";
}
public function index_put($id){
    echo "update: " . $id;
}
public function index_delete($id){
    echo "delete: " . $id;
}
}

我遇到了同样的问题。因此,这不是一个错误 - https://github.com/philsturgeon/codeigniter-restserver/issues/255 - 你必须公开指定"index"作为函数("Interview/index/{id}"),或者给你的方法一个名字("rest_put($id)",所以访问Interview/rest/{id}")