perf(json): replace encoding/json with bytedance/sonic

Migrate all JSON marshaling and unmarshaling operations to use
github.com/bytedance/sonic for improved performance. This affects
adapters, middleware, proxy handlers, and the sync store.
This commit is contained in:
zenfun
2025-12-10 23:21:51 +08:00
parent 770a9fef2b
commit 5826db3954
5 changed files with 13 additions and 12 deletions

View File

@@ -1,9 +1,10 @@
package main
import (
"encoding/json"
"log"
"net/http"
"github.com/bytedance/sonic"
)
func main() {
@@ -30,7 +31,7 @@ func main() {
},
}
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(resp)
_ = sonic.ConfigDefault.NewEncoder(w).Encode(resp)
})
mux.HandleFunc("/v1/models", func(w http.ResponseWriter, r *http.Request) {
@@ -41,7 +42,7 @@ func main() {
},
}
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(resp)
_ = sonic.ConfigDefault.NewEncoder(w).Encode(resp)
})
log.Println("mock-upstream listening on :8082")