什么是gRpcHttp網關
通俗的講就是將gRpc提供的服務以rest api的形式提供出去,不需要再單獨的寫一個webapi去做這件事。
gRpcHttp網關好處
減少不必要代碼,減少中間層提高通訊效率。
以前可能是這樣

用了gRpc網關后是這樣

gRpcHttp網關提供哪些功能
- 可以直接加載proto生成的dll文件
- 可以只需要proto文件,自動解析出proto文件所提供的model和service
- 支持header轉發
- 支持gRpc的四種模式
- 支持gRpc中間件
- 支持swagger(開發中)
- 支持proto和dll文件動態新增,不需要重啟網關
Getting Started
- git clone https://github.com/BuiltCloud/Ocelot.GrpcHttpGateway.git
- cd Ocelot.GrpcHttpGateway/src
- cd samples\OcelotGateway and dotnet run
- cd samples\Examples.GrpcServer and dotnet run
- copy Examples.GrpcModels.dll to samples\OcelotGateway\bin\Debug\netcoreapp2.1\plugins
- curl http://localhost:5000/grpc/PLAYERSEARCH/SEARCHTEAM
- curl http://localhost:5000/grpc/PLAYERSEARCH/SearchPlayer_ServerStream
- curl http://localhost:5000/grpc/PLAYERSEARCH/SearchPlayer_ClientStream
- curl http://localhost:5000/grpc/PLAYERSEARCH/SearchPlayer_DuplexStream
- curl http://localhost:5000/srv 查看當前服務和方法
你還可以復制.proto文件到Examples.GrpcModels.dll to samples\OcelotGateway\bin\Debug\netcoreapp2.1\protos目錄
查看http://localhost:5000/srv變化
