directory
Version:
v1.0.3
Opens a new window with list of versions in this module.
Published: Apr 22, 2025
License: MIT
Opens a new window with license information.
README
¶
example
hephfx/micro实战
gen code
执行如下命令实现go代码生成
sh bin/go-generate.sh
start running
- 先运行命令
go run cmd/rpc/main.go启动服务端。
- 接着执行
go run clients/go/main.go运行客户端。
grpc gateway
- 需要在proto文件添加如下核心配置
import "google/api/annotations.proto";
// Greeter service 定义开放调用的服务
service Greeter {
rpc SayHello (HelloReq) returns (HelloReply){
option (google.api.http) = {
get: "/v1/say/{id}"
};
};
rpc Info (InfoReq) returns (InfoReply){
option (google.api.http) = {
get: "/v1/info/{name}"
};
};
}
- 执行
go run cmd/gateway/main.go即可(启动之前,需要先启动rpc服务端)。
Directories
¶
Click to show internal directories.
Click to hide internal directories.