refactor: move websocket package and some http utils to seperate repo

This commit is contained in:
yusing
2025-09-27 14:16:42 +08:00
parent 6776f20332
commit 2a05c6a630
48 changed files with 52 additions and 1193 deletions

View File

@@ -6,7 +6,7 @@ import (
"strconv"
api "github.com/yusing/godoxy/internal/api/v1"
gphttp "github.com/yusing/godoxy/internal/net/gphttp"
httputils "github.com/yusing/goutils/http"
"github.com/yusing/goutils/http/httpheaders"
)
@@ -79,7 +79,7 @@ func (w *Watcher) wakeFromHTTP(rw http.ResponseWriter, r *http.Request) (shouldN
return false
}
accept := gphttp.GetAccept(r.Header)
accept := httputils.GetAccept(r.Header)
acceptHTML := (r.Method == http.MethodGet && accept.AcceptHTML() || r.RequestURI == "/" && accept.IsEmpty())
isCheckRedirect := r.Header.Get(httpheaders.HeaderGoDoxyCheckRedirect) != ""
@@ -108,7 +108,7 @@ func (w *Watcher) wakeFromHTTP(rw http.ResponseWriter, r *http.Request) (shouldN
err := w.Wake(ctx)
if err != nil {
http.Error(rw, "Internal Server Error", http.StatusInternalServerError)
gphttp.LogError(r).Msg(fmt.Sprintf("failed to wake: %v", err))
httputils.LogError(r).Msg(fmt.Sprintf("failed to wake: %v", err))
return false
}