feat: adding header support for client

This commit is contained in:
2025-11-21 20:01:49 +07:00
parent 4fc0c438c8
commit 9816426780
3 changed files with 55 additions and 69 deletions

View File

@@ -27,7 +27,9 @@ func main() {
wsClient, err := client.NewSafeWebsocketClientBuilder().
BaseHost("localhost").
BasePort(8080).
Path("/ws/test/data_1").
Headers(map[string]string{
"X-MBX-APIKEY": "abcd",
}).Path("/ws/test/data_1").
UseTLS(false).
ChannelSize(1).
Build(ctx)
@@ -44,7 +46,7 @@ func main() {
dataChannel := wsClient.DataChannel()
for data := range dataChannel {
// _ = data
fmt.Println(string(data))
_ = data
// fmt.Println(string(data))
}
}

View File

@@ -17,7 +17,7 @@ func main() {
s, err := server.NewSafeWebsocketServerBuilder().
BaseHost("localhost").
BasePort(8080).
ApiKey("").
ApiKey("abcd").
HandleFuncWebsocket("/ws/test/", "data_1", func(c chan []byte) {
ticker := time.NewTicker(10 * time.Millisecond)
for range ticker.C {