【问题标题】:Restler custom URL routing not workingRestler 自定义 URL 路由不起作用
【发布时间】:2014-08-14 20:26:35
【问题描述】:

在我的 REST API 中,我有与订单关联的工作,因此我使用 Restler (3.0.0-RC6) 创建了这个方法:

class Orders {
    /**
     * Get completed work for order
     *
     * @param int $id The SQL identifier of the order
     *
     * @return array {@type Work}
     *
     * @url GET orders/{id}/works
     */
     function getCompletedWork($id) {

所以现在我转到我的网址并输入 ..../index.php/orders/1/works,然后我从 Routes.php:436 at route stage 得到一个 404

我做错了什么?

【问题讨论】:

    标签: restler


    【解决方案1】:

    自定义路由也与类名一起映射,除非我们在添加 Api 类时提供空字符串作为第二个参数

    $r->addAPIClass('Orders','');
    

    所以你上面的例子实际上映射到orders/orders/{id}/works。你可以修复

    class Orders {
        /**
         * Get completed work for order
         *
         * @param int $id The SQL identifier of the order
         *
         * @return array {@type Work}
         *
         * @url GET {id}/works
         */
         function getCompletedWork($id) {
    

    【讨论】:

      猜你喜欢
      • 2013-11-06
      • 2016-05-10
      • 1970-01-01
      • 2013-11-04
      • 1970-01-01
      • 2019-01-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多