From c719a56ad4db86fa496b961421a84c304caf6dca Mon Sep 17 00:00:00 2001 From: chai2010 Date: Sun, 15 Jul 2018 17:18:48 +0800 Subject: [PATCH] =?UTF-8?q?ch4-07:=20=E5=87=86=E5=A4=87=E6=80=9D=E8=B7=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ch4-rpc/ch4-07-pb-option.md | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/ch4-rpc/ch4-07-pb-option.md b/ch4-rpc/ch4-07-pb-option.md index 63f3b79..c809f7a 100644 --- a/ch4-rpc/ch4-07-pb-option.md +++ b/ch4-rpc/ch4-07-pb-option.md @@ -6,10 +6,19 @@ TODO 基于pb扩展,打造一个自定义的rest生成 -url中参数先简单处理,不支持子结构体内的映射 +支持 url 和 url.Values -参考 gopl 的 unpark 实现 +通过 grpc-gateway/runtime.PopulateFieldFromPath 和 PopulateQueryParameters 天才 protoMsg 成员 -重点是自动生成路由映射,甚至自动关联到 grpc 等服务接口(避免新开一个服务代理) +路由通过 httprouter 处理 + +- https://github.com/julienschmidt/httprouter +- https://github.com/grpc-ecosystem/grpc-gateway/blob/master/runtime/query.go#L20 + +先生成 net/rpc 接口,然后同时增加 Rest 接口 + +扩展的元信息需要一个独立的文件,因为在插件中需要访问。 + +可以新开一个github项目,便于引用 -->