Rebased from main: Old CPU / Old docker version compatibility

This commit is contained in:
yusing
2026-01-16 21:27:37 +08:00
parent 2d0058aebc
commit d73272b8e0
61 changed files with 277 additions and 268 deletions

View File

@@ -3,6 +3,7 @@ package captcha
import (
"bytes"
"context"
"encoding/json"
"errors"
"net"
"net/http"
@@ -11,7 +12,6 @@ import (
_ "embed"
"github.com/bytedance/sonic"
gperr "github.com/yusing/goutils/errs"
)
@@ -70,7 +70,7 @@ func (p *HcaptchaProvider) Verify(r *http.Request) error {
Success bool `json:"success"`
Error []string `json:"error-codes"`
}
if err := sonic.ConfigDefault.NewDecoder(resp.Body).Decode(&respData); err != nil {
if err := json.NewDecoder(resp.Body).Decode(&respData); err != nil {
return err
}

View File

@@ -1,12 +1,12 @@
package middleware
import (
"encoding/json"
"maps"
"net/http"
"reflect"
"sort"
"github.com/bytedance/sonic"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"github.com/yusing/godoxy/internal/serialization"
@@ -152,7 +152,7 @@ func (m *Middleware) MarshalJSON() ([]byte, error) {
commonOptions
any
}
return sonic.MarshalIndent(map[string]any{
return json.MarshalIndent(map[string]any{
"name": m.name,
"options": allOptions{
commonOptions: m.commonOptions,

View File

@@ -3,12 +3,12 @@ package middleware
import (
"bytes"
_ "embed"
"encoding/json"
"io"
"maps"
"net/http"
"net/http/httptest"
"github.com/bytedance/sonic"
"github.com/yusing/godoxy/internal/common"
nettypes "github.com/yusing/godoxy/internal/net/types"
gperr "github.com/yusing/goutils/errs"
@@ -24,7 +24,7 @@ func init() {
return
}
tmp := map[string]string{}
err := sonic.Unmarshal(testHeadersRaw, &tmp)
err := json.Unmarshal(testHeadersRaw, &tmp)
if err != nil {
panic(err)
}

View File

@@ -1,9 +1,8 @@
package nettypes
import (
"encoding/json"
urlPkg "net/url"
"github.com/bytedance/sonic"
)
type URL struct {
@@ -47,7 +46,7 @@ func (u *URL) MarshalJSON() (text []byte, err error) {
if u == nil {
return []byte("null"), nil
}
return sonic.Marshal(u.URL.String())
return json.Marshal(u.URL.String())
}
func (u *URL) Equals(other *URL) bool {