summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorMike Crute <mike@crute.us>2022-01-02 11:49:07 -0800
committerMike Crute <mike@crute.us>2022-01-02 11:49:07 -0800
commit51949f8dc563c7c1ce03d8862abbee4cc1e20943 (patch)
treede8c07df1a0fd4dd47e947ea6d74275ee2c3daa3 /main.go
parent219288c98477e392242e5dcca300d20062b3c670 (diff)
downloadwebsocket_proxy-51949f8dc563c7c1ce03d8862abbee4cc1e20943.tar.bz2
websocket_proxy-51949f8dc563c7c1ce03d8862abbee4cc1e20943.tar.xz
websocket_proxy-51949f8dc563c7c1ce03d8862abbee4cc1e20943.zip
WIP: add contexts
Diffstat (limited to 'main.go')
-rw-r--r--main.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/main.go b/main.go
index ec4170b..00fe063 100644
--- a/main.go
+++ b/main.go
@@ -1,6 +1,7 @@
1package main 1package main
2 2
3import ( 3import (
4 "context"
4 "errors" 5 "errors"
5 "fmt" 6 "fmt"
6 "log" 7 "log"
@@ -34,9 +35,14 @@ var clientCmd = &cobra.Command{
34 Run: func(cmd *cobra.Command, args []string) { 35 Run: func(cmd *cobra.Command, args []string) {
35 listenOn := cmd.Flag("listen").Value.String() 36 listenOn := cmd.Flag("listen").Value.String()
36 37
38 // TODO: Handle signals
39 ctx, cancel := context.WithCancel(context.Background())
40 defer cancel()
41
37 h := &ClientHandler{ 42 h := &ClientHandler{
38 SocketListenOn: listenOn, 43 SocketListenOn: listenOn,
39 WebsocketServer: args[0], 44 WebsocketServer: args[0],
45 Context: ctx,
40 } 46 }
41 47
42 log.Printf("Serving on %s", listenOn) 48 log.Printf("Serving on %s", listenOn)