使用github.com/soheilhy/cmux 监听gRPC和http服务; http接口实现:调用gRPC接口。
- 运行服务
go run server.go
- gRPC调用
tg -c tgrpc.toml -C
- http调用
curl http://localhost:50052/api/helloworld.Greeter/SayHello -H 'customerId:123' -H 'region:UK' --data-binary '{"name":"gRPC&webapi"}' --compressed
curl http://localhost:2080/api/helloworld.Greeter/SayHello -H 'customerId:123' -H 'region:UK' --data-binary '{"name":"gRPC&webapi"}' --compressed