hyperf / hyperf/http-server

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

Đang mở
#13 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
PHP
Star
10
Fork
8
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

例如有路由:`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()`方法,获取路由的所有参数?

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
php
Lĩnh vực
backend
Loại issue
Tính năng
Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
55/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.