Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于http到grpc server的转换 #60

Open
poembro opened this issue Apr 29, 2020 · 5 comments
Open

关于http到grpc server的转换 #60

poembro opened this issue Apr 29, 2020 · 5 comments

Comments

@poembro
Copy link

poembro commented Apr 29, 2020

我看到 https://github.com/wiatingpub/MTBSystem 项目中
单独用net/http做的 http 到 grpc 的路由转换
实现代码 https://github.com/wiatingpub/MTBSystem/blob/master/src/api-srv/main.go

于是在教程的代码里尝试了下发现有报错:
json.RawMessage is not protoiface.MessageV1: missing method ProtoMessage

想问下有没有类似的做法或案例

@printfcoder
Copy link
Member

http转grpc micro api是支持的。
默认的go-micro启动就是grpc风格的服务,micro api可以代理http转向go-micro。实现也很简单,将路由映射解析成服务+方法,router->service+method。然后调用具体的服务就行了

@printfcoder
Copy link
Member

@poembro
Copy link
Author

poembro commented May 14, 2020

http转grpc micro api是支持的。
替代的go-micro启动就是grpc风格的服务,micro api可以代理http转向go-micro。实现也很简单,将路由映射解析成服务+方法,rou​​ter-> service +方法。然后调用具体的服务就行了

感谢解答!

关于 ”rou​​ter-> service +方法“ 我理解就是 micro api 网关的 --handler=rpc 参数。

如果按照 https://github.com/wiatingpub/MTBSystem/blob/master/src/api-srv/main.go 这个方案来实现,好像更加灵活(比如:收集日志,访问量,统一鉴权等等), 不知道大家生产环境推荐哪种做法。

@ntboot
Copy link

ntboot commented Nov 9, 2020

我看到 https://github.com/wiatingpub/MTBSystem 项目中
单独用net/http做的 http 到 grpc 的路由转换
实现代码 https://github.com/wiatingpub/MTBSystem/blob/master/src/api-srv/main.go

于是在教程的代码里尝试了下发现有报错:
json.RawMessage is not protoiface.MessageV1: missing method ProtoMessage

想问下有没有类似的做法或案例

您的这个问题解决了吗,我也想通过net/http 实现一个api网关, 而不是通过handel=rpc方式

@ntboot
Copy link

ntboot commented Nov 9, 2020

我看到 https://github.com/wiatingpub/MTBSystem 项目中
单独用net/http做的 http 到 grpc 的路由转换
实现代码 https://github.com/wiatingpub/MTBSystem/blob/master/src/api-srv/main.go
于是在教程的代码里尝试了下发现有报错:
json.RawMessage is not protoiface.MessageV1: missing method ProtoMessage
想问下有没有类似的做法或案例

您的这个问题解决了吗,我也想通过net/http 实现一个api网关, 而不是通过handel=rpc方式

我现在的问题也和你一样的报错

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants