improved HTTP performance, especially when match_domains are used; api json string fix

This commit is contained in:
yusing
2024-11-02 07:14:03 +08:00
parent 46b4090629
commit 625bf4dfdc
4 changed files with 48 additions and 34 deletions

View File

@@ -2,6 +2,7 @@ package utils
import (
"encoding/json"
"fmt"
"net/http"
"github.com/yusing/go-proxy/internal/logging"
@@ -23,7 +24,7 @@ func RespondJSON(w http.ResponseWriter, r *http.Request, data any, code ...int)
switch data := data.(type) {
case string:
j = []byte(`"` + data + `"`)
j = []byte(fmt.Sprintf("%q", data))
case []byte:
j = data
default: