【发布时间】:2017-11-08 12:46:43
【问题描述】:
这就是我为我的 api 定义路由的方式。它以 /api/v1 为前缀。但是现在 api v2 中添加了一些新模块,并且所有 v1 api 都保持不变并且在 v2 中可用。我如何修改这些路由,以服务于属于 /api/v1 的所有路由,并且当 /api/v1 被调用时,它应该在 /api/v2 被调用时同时服务于 /api/v2 和 /api/v1?
module.config.php
'product' => array(
'type' => 'Zend\Router\Http\Segment',
'options' => array(
'route' => '/api/v1/categories[/:id]',
'defaults' => array(
'controller' => CategoryController::class,
),
),
),
'products' => array(
'type' => 'Zend\Router\Http\Segment',
'options' => array(
'route' => '/api/v1/products[/:id]',
'defaults' => array(
'controller' => ProductsController::class,
),
),
),
// ... at lots of v1 apis
//these are introduced in v2
'trends' => array(
'type' => 'Zend\Router\Http\Segment',
'options' => array(
'route' => '/api/v2/trends[/:id]',
'defaults' => array(
'controller' => TrendsController::class,
),
),
),
【问题讨论】:
标签: php zend-framework3 zend-route