mirror of
https://github.com/balzack/databag.git
synced 2025-02-12 11:39:17 +00:00
27 lines
510 B
Go
27 lines
510 B
Go
package databag
|
|
|
|
import (
|
|
"net/url"
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"github.com/gorilla/websocket"
|
|
)
|
|
|
|
type StatusHandler struct {}
|
|
|
|
func (h *StatusHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|
Status(w, r)
|
|
}
|
|
|
|
func getTestWebsocket() *websocket.Conn {
|
|
h := StatusHandler{}
|
|
s := httptest.NewServer(&h)
|
|
wsUrl, _ := url.Parse(s.URL)
|
|
wsUrl.Scheme = "ws"
|
|
ws, _, err := websocket.DefaultDialer.Dial(wsUrl.String(), nil)
|
|
if err != nil {
|
|
PrintMsg(err.Error());
|
|
}
|
|
return ws
|
|
}
|