222twotwotwo opened a new pull request, #153:
URL: https://github.com/apache/dubbo-go-pixiu-samples/pull/153
<!-- Thanks for sending a pull request!
-->
**What this PR does**:
这个 PR 修复了 `dubbohttpproxy/server/http` 示例中 Dubbo -> HTTP 转发链路的业务语义问题。此前 HTTP
handler 期望请求体是 JSON 字符串,但 Pixiu 的 Dubbo generic 调用实际发送的是参数数组,例如
`["0001"]`,导致反序列化失败、错误信息被拼进响应 body,并且 miss 时会写入 `Name=""` 的错误 cache entry。
- 重写 `dubbohttpproxy/server/http` 的 `user()` handler,使其接受 Pixiu Dubbo
generic 调用实际发送的参数数组 body(`["0001"]`)。
- 对非法 body、缺少参数、用户不存在和不支持的方法分别返回明确的 `400`、`404`、`405` 状态码,并保证所有错误路径都会提前
`return`。
- 删除 miss 时随机创建用户的逻辑,避免继续污染 `Name=""` 的 cache entry。
- 将 `UserDB.Add` 改为按用户 ID 写入 HTTP 样例缓存,使 `GetUserById("0001")` 返回预置的 `tc`
用户记录。
- 新增 `dubbohttpproxy/server/http/server_test.go`,覆盖成功查询、用户不存在、错误
schema、空参数、cache 不污染和不支持的方法。
**Which issue(s) this PR fixes**:
<!--
*Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
_If PR is about `failing-tests or flakes`, please post the related
issues/tests in a comment and do not use `Fixes`_*
-->
Fixes #
**Does this PR introduce a user-facing change?**:
<!--
If no, just write "NONE" in the release-note block below.
If yes, a release note is required:
Enter your extended release note in the block below. If the PR requires
additional action from users switching to the new release, include the string
"action required".
-->
```release-note
NONE
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]