Actix-web、Rocket 等框架支持这样的写法:

#[get("/users/{id}")]
async fn show(id: web::Path<i32>) -> impl Responder { /* ... */ }

很多人觉得这"很优雅"——一个属性宏挂在函数上方,路径、方法、参数一目了然,像 Spring MVC 的 @GetMapping,像 FastAPI 的 @app.get。每隔一段时间,就有人在 Salvo 的 issue 区问:能不能也加一个 #[get]

Salvo 故意没有采用。本文想认真解释这个决定背后的原因。

阅读全文