cloudwego / volo

Rust RPC framework with high-performance and strong-extensibility for building micro-services.
https://crates.io/crates/volo
Apache License 2.0
2.13k stars 166 forks source link

基于 UrlParams 的使用场景,对其进行重命名的建议。 #415

Closed liuxin231 closed 2 months ago

liuxin231 commented 2 months ago

Feature Request

Crates

volo-http

Motivation

增强可用性和可读性。

Proposal

根据提交的UrlParams参数提取方式进行测试后发现只会提取Path内的参数,如 axum 框架内 /api/:id 的使用方式,并不会提取url问号后的参数,该参数命名是否可以参考其他框架的命名,也为后续的其他参数提取留出空间。

Alternatives

修改 UrlParams 为 PathParams 或 Path.

wfly1998 commented 2 months ago

PathParams 确实会比 UrlParams 描述更准确一些,我稍后提个 PR 修改一下。

不过你提到的 “问号后的参数” 这个其实叫 query,在 volo-http 中可以用 Query 来提取。

liuxin231 commented 2 months ago

了解,不知道这个修改我是否可以进行,想要参与该框架的贡献,为后续贡献熟悉流程可以咩,不知道是否已经分配。

wfly1998 commented 2 months ago

可以的,不过为了避免这种名字修改导致的 break change,建议修改后再保留一个 alias,比如

--- pub struct UrlParams<T> { ... }
+++ pub struct PathParams<T> { ... }
+++
+++ pub type UrlParams<T> = PathParams<T>;

在后续的版本中,我可以为 UrlParams 添加 deprecated 标记。

liuxin231 commented 2 months ago

了解,稍后提交。