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"
config "github.com/yusing/go-proxy/internal/config/types"
"github.com/yusing/go-proxy/internal/net/gphttp"
"github.com/yusing/go-proxy/internal/net/gphttp/gpwebsocket"
@@ -15,7 +14,7 @@ import (
func ListRouteProvidersHandler(cfgInstance config.ConfigInstance, w http.ResponseWriter, r *http.Request) {
if httpheaders.IsWebsocket(r.Header) {
gpwebsocket.Periodic(w, r, 5*time.Second, func(conn *websocket.Conn) error {
return wsjson.Write(r.Context(), conn, cfgInstance.RouteProviderList())
return conn.WriteJSON(cfgInstance.RouteProviderList())
})
} else {
gphttp.RespondJSON(w, r, cfgInstance.RouteProviderList())