【问题标题】:Restler 3 Custom RoutingRestler 3 自定义路由
【发布时间】:2013-11-06 07:33:00
【问题描述】:

我一直在寻找在 Restler 3 中创建手动/自定义路由以实现这样的 URL 的示例。

http://domain.com/api/v1/solution/categories/{category-id}/folders/{folder-id}/articles/{article-id}.json

我想要解决方案类处理的所有内容。我想为每个 get() 提供一个单独的方法。这可能吗?

Defaults::$useUrlBasedVersioning = true;
$r = new Restler();
$r->setSupportedFormats('JsonFormat', 'XmlFormat');
$r->setAPIVersion(1);
$r->addAPIClass('Luracast\\Restler\\Resources');
$r->addAPIClass('Solution');
$r->addAuthenticationClass('AccessControl');
$r->handle();

到目前为止,我已经尝试过路由示例,但没有成功。

http://restler3.luracast.com/examples/_006_routing/readme.html

【问题讨论】:

    标签: php restler


    【解决方案1】:

    这是一个工作示例

    <?php
    
    class Solution
    {
    
        /**
         * @url GET categories/{category_id}/folders/{folder_id}/articles/{article_id}
         */
        public function categories($category_id, $folder_id, $article_id)
        {
            return func_get_args();
        }
    
    } 
    

    【讨论】:

    • Restler 的精心设计真是令人惊叹。非常感谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多