From 1cb63063f7b6eb49f2f8f986ca5cae74d12a7bb7 Mon Sep 17 00:00:00 2001 From: CaIon Date: Fri, 15 Aug 2025 14:52:17 +0800 Subject: [PATCH] refactor: replace json.Marshal and json.Unmarshal with common.Marshal and common.Unmarshal --- relay/responses_handler.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/relay/responses_handler.go b/relay/responses_handler.go index cd80da33..40c5e161 100644 --- a/relay/responses_handler.go +++ b/relay/responses_handler.go @@ -2,7 +2,6 @@ package relay import ( "bytes" - "encoding/json" "fmt" "io" "net/http" @@ -48,21 +47,21 @@ func ResponsesHelper(c *gin.Context, info *relaycommon.RelayInfo) (newAPIError * if err != nil { return types.NewError(err, types.ErrorCodeConvertRequestFailed, types.ErrOptionWithSkipRetry()) } - jsonData, err := json.Marshal(convertedRequest) + jsonData, err := common.Marshal(convertedRequest) if err != nil { return types.NewError(err, types.ErrorCodeConvertRequestFailed, types.ErrOptionWithSkipRetry()) } // apply param override if len(info.ParamOverride) > 0 { reqMap := make(map[string]interface{}) - err = json.Unmarshal(jsonData, &reqMap) + err = common.Unmarshal(jsonData, &reqMap) if err != nil { return types.NewError(err, types.ErrorCodeChannelParamOverrideInvalid, types.ErrOptionWithSkipRetry()) } for key, value := range info.ParamOverride { reqMap[key] = value } - jsonData, err = json.Marshal(reqMap) + jsonData, err = common.Marshal(reqMap) if err != nil { return types.NewError(err, types.ErrorCodeConvertRequestFailed, types.ErrOptionWithSkipRetry()) }