pub async fn fetch_post_data(req: Request<Body>) -> Result<Value, String>Expand description
从请求中获取合并参数(body + query)
对齐 PHP $this->request->param():合并 POST body 和 GET query,
body 中的字段优先级高于 query。
§参数
req:axum::http::Request<Body>
§返回
Ok(Value::Object):合并后的 JSON ObjectErr(String):body 不可读或 JSON 解析失败
§行为
- 解析 query string 为
Value::Object(每个键值对均为字符串) - 读取 body bytes
- 如果 Content-Type 为
application/json,解析 body 为 JSON 并合并到 query - 如果 Content-Type 为
application/x-www-form-urlencoded,解析为表单并合并 - body 字段覆盖 query 字段