cakephp - Cakephp 触发错误路由
问题描述
我的路由有问题。我有一个用 Cakephp 3.9 编码的 API,当我调用它时,它会调用我另一个路由。
我想/api/order/customer-quotation
通过 POST 调用路由,但是调用了/api/order/:id
GET 路由...
这是我的代码的捕获:
Router::plugin('Api', ['path' => '/api'], function ($routes) {
$routes->registerMiddleware(
'api-firewall',
new \Api\Middleware\ApiFirewallMiddleware()
);
$routes->applyMiddleware('api-firewall');
$routes->scope('/order', ['controller' => 'Order'], function($routes) {
$routes
->connect(
'/customer-quotation',
['action' => 'createOrder'],
['_name' => 'create_order']
)
->setMethods(['POST']);
$routes
->connect(
'/:id',
['action' => 'getOrderDetails'],
['_name' => 'order_details']
)
->setMethods(['GET']);
});
我无法理解
谢谢
解决方案
推荐阅读
- python - 带分数的复数
- azure - 如何向 Azure AppService (WebApp) 添加自定义区域性 (en-cn)?
- python - 提取Html表格后如何在csv中单行写入td(表格数据)?
- mobile - 在 gluon mobile 中读取 udp 图像
- c# - 如何对角裁剪图像?
- ionic-framework - MQTT 连接创建和订阅
- python - 如何覆盖 django save 方法以动态更新某些字段?
- spring-boot - Spring OAuth2.0:根据ClientId(授权码授予类型)获取用户角色
- rinsim - 结合 WareHouseModel 和 Experiments
- ubuntu-16.04 - 尝试在 HTTP/2 上 POST,但 libcurl 正在 HTTP/1.1 上连接