例如,我使用此代码为测试路线:苗条框架和GET/PUT/POST方法
$app->get('/api', function() {
echo 'get!';
});
$app->post('/api', function() {
echo 'post!';
});
$app->put('/api', function() {
echo 'put!';
});
对于API测试我使用RESTClient实现插件铬。
当我尝试做GET请求时,响应是'get!'。这很好。
但是:
当我尝试做POST请求,响应也就是 '搞定了!'。为什么?它必须是'post!'。
当我尝试做PUT请求,(在响应头:允许:GET,HEAD,POST,OPTIONS,TRACE)苗条响应具有405错误(不允许的方法)与消息:
“URL/api不允许请求的方法PUT”。
我在做什么错?
它使用为我的作品[高级REST客户端(https://chrome.google.com/webstore/detail/advanced- rest-client/hgmloofddffdnphfgcellkdfbfbjeloo)和[DHC-REST/HTTP API客户端](https://chrome.google.com/webstore/detail/dhc-resthttp-api-client/aejoelaoggembcahagimdiliamlcdmfm)。你添加了''.htaccess''文件吗? – 2015-02-09 08:42:21
是的,这是我的htaccess:! RewriteEngine叙述在 RewriteBase/ 的RewriteCond%{} REQUEST_FILENAME -f 的RewriteCond%{} REQUEST_FILENAME -d 重写规则^/$的index.php – hcuser 2015-02-09 11:12:31
尝试使用[此(*)。酮](https://raw.githubusercontent.com/codeguy/Slim/master/.htaccess)。 – 2015-02-09 11:40:14