测试Grpc接口的方法(grpcui/grpcurl)
1.首先需要搭建go环境,自行安装
2.安装grpcurl
2.1 安装Windows插件
官方地址:https://github.com/fullstorydev/grpcurl
安装:go install github.com/fullstorydev/grpcurl/cmd/grpcurl@latest
安装grpcurl可能会报错
- 解决grpcurl报错
因为防火墙的原因所以会被屏蔽,执行下面这个内容应该就没问题了
go env -w GOPROXY=https://goproxy.cn
2.2 安装Grpcui
官方地址:https://github.com/fullstorydev/grpcui
安装:go install github.com/fullstorydev/grpcui/cmd/grpcui@latest
3.grpcurl请求
请求样式:
grpcurl -plaintext -d '{
\"header\": {
\"name\": \"11122\",
\"num\": \"1.000000000000000000\",
},
\"Detail\": {
\"address\": \"asdasdasdasdasd\",
\"confirmations\": 30,
},
\"sex\": \"1\",
\"userId\": \"56465\",
\"status\": 2,
}' 10.xxxxx:8081 api.xxxx
4.grpcui访问
通过grpcui访问grpc接口
grpcui -plaintext 服务器ip:开放的端口号
grpcui -plaintext 10.564.13.1:8080