mirror of
https://github.com/yusing/godoxy.git
synced 2026-03-31 14:13:09 +02:00
refactor: refactor to adapt new custom json marshaler
This commit is contained in:
@@ -12,7 +12,6 @@ import (
|
||||
"github.com/yusing/go-proxy/internal/logging"
|
||||
"github.com/yusing/go-proxy/internal/net/gphttp"
|
||||
"github.com/yusing/go-proxy/internal/net/gphttp/httpheaders"
|
||||
"github.com/yusing/go-proxy/internal/utils"
|
||||
)
|
||||
|
||||
func warnNoMatchDomains() {
|
||||
@@ -95,7 +94,7 @@ func WriteText(r *http.Request, conn *websocket.Conn, msg string) bool {
|
||||
func DynamicJSONHandler[ResultType any](w http.ResponseWriter, r *http.Request, getter func() ResultType, interval time.Duration) {
|
||||
if httpheaders.IsWebsocket(r.Header) {
|
||||
Periodic(w, r, interval, func(conn *websocket.Conn) error {
|
||||
return wsjson.Write(r.Context(), conn, utils.ToJSONObject(getter()))
|
||||
return wsjson.Write(r.Context(), conn, getter())
|
||||
})
|
||||
} else {
|
||||
gphttp.RespondJSON(w, r, getter())
|
||||
|
||||
Reference in New Issue
Block a user