grpcwebsocket

command
v2.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 29, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

README

Gateway Multi-Protocol Example

同一套 gRPC handler,同时暴露:

端口 前端
:8080 HTTP/REST + gRPC-Web(Fiber)
:8081 WebSocket(net/http)
:50051 Native gRPC

演示本轮契约:

  • gatewayserver.NewGatewaySurface 装配入口
  • Mux.UseRPCMiddleware(响应头 X-Example-Mw)
  • gRPC-Web 成功 trailer / gzip 压缩协商
  • HTTP 拒绝 client/bidi(/v1/greeter/chat → Unimplemented)

Run

go run ./internal/examples/grpcwebsocket

浏览器:http://localhost:8080/

Verify

# 另开终端
go run ./internal/examples/grpcwebsocket/verify/

覆盖:HTTP/JSON、HTTP client-stream 拒绝、gRPC-Web unary/gzip/server-stream、WS 四流、native gRPC。

  • JS SDK(HTTP/JSON + gRPC-Web):sdk/js/gateway-client(@pubgo/lava-gateway-client)
  • HTTP/gRPC-Web 精简示例:internal/examples/grpcweb(前端消费 SDK)
  • 设计文档:pkg/gateway/docs/design-evolution.md

Documentation

Overview

Package main 提供 Gateway 多协议示例:同一套 gRPC handler 同时暴露 HTTP/REST + gRPC-Web、WebSocket、Native gRPC。

运行:

go run ./internal/examples/grpcwebsocket

验证(需先启动本服务):

go run ./internal/examples/grpcwebsocket/verify/

Directories

Path Synopsis
Command verify exercises every gateway frontend exposed by the grpcwebsocket example.
Command verify exercises every gateway frontend exposed by the grpcwebsocket example.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL