hyperf / hyperf/http-server

可否增加获取路由所有参数的方法?

未关闭
#13 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
PHP
星标
10
派生
8
PR 合并指标
30 天内没有已合并 PR

描述

例如有路由:`path/{paramA}/{paramB}`,需求是想获取所有的参数,即`paramA`和`paramB`。

但目前只有`route`方法,只能获取单个路由参数,对应代码如下:
```php
/**
* Retrieve the data from route parameters.
*/
public function route(string $key, mixed $default = null): mixed
{
/** @var null|Dispatched $route */
$route = $this->getAttribute(Dispatched::class);
if (is_null($route)) {
return $default;
}
return array_key_exists($key, $route->params) ? $route->params[$key] : $default;
}
```

能否新增`routes()`方法,获取路由的所有参数?

贡献指南

这个仓库没有索引到贡献指南

调研方向

Start from the request class containing the shown route() method and inspect how the Dispatched route attribute exposes its params. Add the requested routes() behavior so all route parameters are returned, then verify that it preserves the existing handling when no dispatched route is available.

由索引模型根据 Issue 内容生成。

评估

技术栈
php
领域
backend
Issue 类型
功能
难度
2/5
预计耗时
1-3 小时
活跃度
停滞
描述清晰度
基本清楚
新手友好度
55/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。