grpcui

简介

grpcui通过web的方式对grpc进行调试,类似于postman对http接口的调试。

github地址

https://github.com/fullstorydev/grpcui

安装

官网:https://github.com/fullstorydev/grpcui

go get github.com/fullstorydev/grpcui
go install github.com/fullstorydev/grpcui/cmd/grpcui

启动服务

# 启动本地RPC服务 
# grpcui 绑定本地 grpc 的 8080 服务端口(grpc服务端口) 
# -bind 192.168.13.38 为本地主机的ip,不填写为127.0.0.1
Administrator@haima-PC MINGW64 /d/code/go/src/go-zero
$ grpcui -bind localhost -plaintext 127.0.0.1:8080
gRPC Web UI available at http://localhost:52855/

note:注意关闭防火墙
     systemctl disable firewalld

浏览器访问

http://localhost:52855/

请求服务

使用方式 postman 差不多

如果启动服务报以下错误

$ grpcui -bind localhost -plaintext 127.0.0.1:8082
Failed to compute set of methods to expose: server does not support the reflection API

解决方法

在 main.go 添加

//注册反射
reflection.Register(s) 

go-zero里已经添加过了,我们只需要修改配置里的启动模式为dev即可

参考文档:
https://blog.csdn.net/javaxflinux/article/details/105997872

作者:admin  创建时间:2023-01-05 07:59
最后编辑:admin  更新时间:2024-05-10 15:32