首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >子路由,分段路由和子路由,而不是路由

子路由,分段路由和子路由,而不是路由
EN

Stack Overflow用户
提问于 2015-07-28 04:37:06
回答 1查看 265关注 0票数 0

这里的顶级路由器能工作。/property是一个不终止并在子路由上获取GET操作的文字路由。在下面,我有一个段路由,和它的父路径一样,它不会终止并在子路由上获取GET操作。它应该只响应/property/12上的GET请求

我在那里路由时发现了一个没有发现的错误。

代码语言:javascript
复制
'router' => array(
    'routes' => array(
        'property' => array(
            'type'    => 'Literal',
            'options' => array(
                'route'    => '/property',
            ),
            'may_terminate' => false,
            'child_routes' => array(
                'get' => array(
                    'type' => 'method',
                    'options' => array(
                        'verb' => 'GET',
                        'defaults' => array(
                            'controller' => 'Property\Controller\Rest',
                            'action' => 'get',
                        ),
                    ),
                ),
                'by_id' => array(
                    'type' => 'segment',
                    'options' => array(
                        'route' => '/[:propertyId]',
                        'may_terminate' => false,
                        'child_routes' => array(
                            'get_by_id' => array(
                                'type' => 'method',
                                'options' => array(
                                    'verb' => 'GET',
                                    'defaults' => array(
                                        'controller' => 'Property\Controller\Rest',
                                        'action' => 'getById',
                                    ),
                                ),
                            ),
                        )
                    ),
                ),
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-07-28 08:50:05

数组无效。'may_terminate'不应该在'options'内部。不确定这是否是导致所有问题的原因,但请尝试更新并查看是否已解决:

代码语言:javascript
复制
            'by_id' => array(
                'type' => 'segment',
                'options' => array(
                    'route' => '/[:propertyId]'
                ),
                'may_terminate' => false,
                'child_routes' => array(
                    'get_by_id' => array(
                        'type' => 'method',
                        'options' => array(
                            'verb' => 'GET',
                            'defaults' => array(
                                'controller' => 'Property\Controller\Rest',
                                'action' => 'getById'
                            )
                        )
                    )
                )
            ),
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31667465

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档