Alanxtl commented on code in PR #1109: URL: https://github.com/apache/dubbo-go-samples/pull/1109#discussion_r3620348498
########## rpc/rest/README_CN.md: ########## @@ -0,0 +1,92 @@ +# Dubbo-Go REST 示例 + +这个示例用于验证 Dubbo-Go REST 协议的三种地址获取方式: + +- 直连 URL +- 接口级注册 +- 应用级服务发现 + +示例通过本地 REST 配置显式声明 HTTP 方法、路径参数、查询参数、请求头和请求体映射。 + +## 运行 + +默认模式是 Nacos 应用级服务发现: + +```bash +go run ./rpc/rest/go-server/cmd +``` + +在另一个终端运行消费者: + +```bash +go run ./rpc/rest/go-client/cmd +``` + +期望输出: + +```text +REST response: userID=101 name=dubbo-go traceID=trace-rest-basic message=body-from-dubbo-rest-client greeting="hello dubbo-go, userID=101, traceID=trace-rest-basic, message=body-from-dubbo-rest-client" +``` + +Provider 同时也是一个普通 HTTP 服务,可以直接用 `curl` 调用: + +```bash +curl -s \ + -X POST 'http://127.0.0.1:20080/api/v1/users/202/greeting?name=curl' \ + -H 'Content-Type: application/json' \ + -H 'Accept: application/json' \ + -H 'X-Trace-ID: trace-curl' \ + -d '{"message":"body-from-curl"}' +``` + +## REST 映射 + +Provider URL 只提供网络目标,例如: Review Comment: done ########## README_CN.md: ########## @@ -70,6 +70,7 @@ * `rpc/jsonrpc`:基于 JSON-RPC 协议的示例。 * `rpc/triple`:Triple 协议示例,涵盖多种序列化方式。 * `rpc/triple/openapi`:演示如何为 Triple 协议服务启用 OpenAPI 文档,包括多版本服务和非 IDL 服务的注册。 + * `rpc/rest`:基于 Rest 协议的示例。 Review Comment: done -- 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]
