Documentation
¶
Overview ¶
helloworld-server 演示 OneXMesh 的「protobuf IDL 驱动的 gRPC + Gin 统一」:
- 单一 IDL:examples/helloworld/proto/hello.proto 定义 service 方法、请求/响应 message, 以及 onexmesh.v1.http 注解(HTTP 路由)。
- 单一实现:greeterService 一个 struct 同时实现 GreeterServer(gRPC)与生成的 HTTP 路由, SayHello 对应 GET /helloworld/{name}(path 参数),SayHelloPost 对应 POST /helloworld(body)。
- 一行装配:proto.NewGreeterService(srv) 把 gRPC 与 HTTP 注册打包成一个 server.Service, 业务方无需写 grpc.ServiceRegistrar / 路由装配样板。
- 纯 HTTP 端点(无 proto 定义):healthz / users / search / api 直接基于 server.NewGinEngine 返回的 原生 *gin.Engine 以 Gin 风格注册(Group/GET/...,支持前缀 / 分组 / 嵌套 / 组中间件)。
- 按需开启:opts.Mesh.Protocol = grpc|http|both 控制只起 gRPC / 只起 Gin / 双起。
- 灵活定制:requestID 自定义中间件(双协议)。
Click to show internal directories.
Click to hide internal directories.