File tree Expand file tree Collapse file tree 2 files changed +37
-1
lines changed Expand file tree Collapse file tree 2 files changed +37
-1
lines changed Original file line number Diff line number Diff line change @@ -10,3 +10,39 @@ into your existing Go webserver to provide WebSocket reverse proxy.
10
10
go get github.com/koding/websocketproxy
11
11
```
12
12
13
+ ## Usage
14
+
15
+ Below is a simple app that runs on a server and proxies to the given backend url
16
+
17
+ ``` bash
18
+ go run proxy.go -backend ws://example.com -port 80
19
+ ```
20
+
21
+ ``` go
22
+ package main
23
+
24
+ import (
25
+ " flag"
26
+ " net/http"
27
+ " net/url"
28
+
29
+ " github.com/koding/websocketproxy"
30
+ )
31
+
32
+ var (
33
+ flagPort = flag.String (" port" , " 3000" , " Port of the reverse proxy" )
34
+ flagBackend = flag.String (" backend" , " " , " Backend URL for proxying" )
35
+ )
36
+
37
+ func main () {
38
+ u , err := url.Parse (*flagBackend)
39
+ if err != nil {
40
+ log.Fataln (err)
41
+ }
42
+
43
+ err := http.ListenAndServe (" :" +*flagPort, websocketproxy.NewProxy (u))
44
+ if err != nil {
45
+ log.Fataln (err)
46
+ }
47
+ }
48
+ ```
Original file line number Diff line number Diff line change 1
- // Package websocketproxy is a reverse websocket proxy handler
1
+ // Package websocketproxy is a reverse proxy for WebSocket connections.
2
2
package websocketproxy
3
3
4
4
import (
You can’t perform that action at this time.
0 commit comments