Simple HTTP client & server long poll library for Go.
This library is useful if you cannot use websocket. If you can use websocket, you should use github.com/gorilla/websocket
See: https://github.com/didip/gomet/tree/master/_examples
cd _examples
go run server.go &
go run client.go &
go run client.go &
curl -H "Content-Type: application/json" -X POST -d '{"message":"hello world"}' http://localhost:8080/
-
Server-side broadcaster conforms to regular HTTP request handler. This means it can be part of middleware stacks.
-
Broadcaster is able to send raw binary since every payload is base64 encoded.
-
Client automatically reconnects when disconnected.
-
Client's HTTP client and HTTP request are customizable.
lp, err := gomet.NewClient("https://localhost:8080/stream") lp.HTTPClient.Transport = &http.Transport{ TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, } req, _ := http.NewRequest("GET", "https://localhost:9090/stream", nil) lp.HTTPRequest = req
-
Define your own error handling for client-side.
lp, err := gomet.NewClient("http://localhost:8080/stream") lp.SetOnConnectError(func(err error) { println("ERROR: Failed to maintain HTTP connection. URL: " + lp.HTTPRequest.URL.String()) }) lp.SetOnReadBytesError(func(err error) { println("ERROR: Failed to read payload: " + err.Error()) }) lp.SetOnBase64DecodeError(func(err error) { println("ERROR: Failed to read payload: " + err.Error()) }) lp.SetOnPayloadReceived(func(payloadBytes []byte) { println("INFO: Received a line: " + string(payloadBytes)) })
-
Tollbooth: Simple middleware to rate-limit HTTP requests.
-
Stopwatch: A small library to measure latency of things. Useful if you want to report latency data to Graphite.
-
LaborUnion: A worker pool library. It is able to dynamically resize the number of workers.