【问题标题】:Luracast Restler - routing one object/list of object in one routing ruleLuracast Restler - 在一个路由规则中路由一个对象/对象列表
【发布时间】:2014-04-17 08:48:54
【问题描述】:

我不知道如何配置路由类以在一个索引方法中路由它:

类别/176
类别/?depth=3&category=4

第一个 URL 用于一个类别,第二个 URL 用于类别列表(按深度和类别参数过滤)。

我有这个方法的类类别:

/**
* @smart-auto-routing false
*/
public function index($category_id) {
}

好的,这适用于 categories/176,但是如何将 categories/?depth=3&category=4 路由添加到此索引方法?

【问题讨论】:

    标签: php url-routing restler


    【解决方案1】:
    Class Categories
    {
    
        public function index($depth=3, $category=4) {
            //categories?depth=3&category=4 received here
            //since they have default values we can call
            //categories with out any query param too!
        }
    
        public function get($id){
            //categories/176 received here
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2014-12-16
      • 1970-01-01
      • 1970-01-01
      • 2014-12-27
      • 2013-04-24
      • 2017-10-04
      • 2018-12-03
      • 2020-05-17
      • 1970-01-01
      相关资源
      最近更新 更多