tweak: replace coder/websocket with gorilla/websocket

This commit is contained in:
yusing
2025-05-19 23:15:11 +08:00
parent cee6eaecff
commit 1f50ee7f2f
16 changed files with 96 additions and 83 deletions

View File

@@ -4,8 +4,7 @@ import (
"net/http"
"time"
"github.com/coder/websocket"
"github.com/coder/websocket/wsjson"
"github.com/gorilla/websocket"
"github.com/yusing/go-proxy/internal/net/gphttp"
"github.com/yusing/go-proxy/internal/net/gphttp/gpwebsocket"
"github.com/yusing/go-proxy/internal/net/gphttp/httpheaders"
@@ -15,7 +14,7 @@ import (
func Health(w http.ResponseWriter, r *http.Request) {
if httpheaders.IsWebsocket(r.Header) {
gpwebsocket.Periodic(w, r, 1*time.Second, func(conn *websocket.Conn) error {
return wsjson.Write(r.Context(), conn, routes.HealthMap())
return conn.WriteJSON(routes.HealthMap())
})
} else {
gphttp.RespondJSON(w, r, routes.HealthMap())