refactor: replace json.Marshal with common.Marshal for consistency and error handling

This commit is contained in:
CaIon
2025-08-28 13:51:07 +08:00
parent cebba71d7c
commit 906f797be5
2 changed files with 13 additions and 8 deletions
+2 -3
View File
@@ -1,7 +1,6 @@
package helper
import (
"encoding/json"
"errors"
"fmt"
"net/http"
@@ -42,7 +41,7 @@ func SetEventStreamHeaders(c *gin.Context) {
}
func ClaudeData(c *gin.Context, resp dto.ClaudeResponse) error {
jsonData, err := json.Marshal(resp)
jsonData, err := common.Marshal(resp)
if err != nil {
common.SysError("error marshalling stream response: " + err.Error())
} else {
@@ -104,7 +103,7 @@ func WssString(c *gin.Context, ws *websocket.Conn, str string) error {
}
func WssObject(c *gin.Context, ws *websocket.Conn, object interface{}) error {
jsonData, err := json.Marshal(object)
jsonData, err := common.Marshal(object)
if err != nil {
return fmt.Errorf("error marshalling object: %w", err)
}