grpcwebsocket

command
v2.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package main 提供 Gateway WebSocket 示例服务。

本示例演示如何通过 coder/websocket 前端调用已注册的 gRPC handler。 WebSocket 前端运行在标准 net/http 栈上,与 Fiber 上的 HTTP/gRPC-Web 前端并存。

运行:

go run ./internal/examples/grpcwebsocket

测试:

  1. 浏览器打开 http://localhost:8080/

  2. 点击 SayHello / SayGoodbye 按钮,WebSocket 连接 ws://localhost:8081/...

  3. curl 无法直接测试 WS,请使用浏览器或 wscat

  4. 原生 gRPC 客户端连接 localhost:50051(与 HTTP/WS 共享同一套 handler)

  5. 自动化验证(需先启动本服务):

    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