Init V4 community edition (#2265)

* Init V4 community edition

* Init V4 community edition
This commit is contained in:
AaronLiu
2025-04-20 17:31:25 +08:00
committed by GitHub
parent da4e44b77a
commit 21d158db07
597 changed files with 119415 additions and 41692 deletions

View File

@@ -2,24 +2,27 @@ package serializer
import (
"bytes"
"context"
"encoding/base64"
"encoding/gob"
)
// Response 基础序列化器
type Response struct {
Code int `json:"code"`
Data interface{} `json:"data,omitempty"`
Msg string `json:"msg"`
Error string `json:"error,omitempty"`
Code int `json:"code"`
Data interface{} `json:"data,omitempty"`
AggregatedError interface{} `json:"aggregated_error,omitempty"`
Msg string `json:"msg"`
Error string `json:"error,omitempty"`
CorrelationID string `json:"correlation_id,omitempty"`
}
// NewResponseWithGobData 返回Data字段使用gob编码的Response
func NewResponseWithGobData(data interface{}) Response {
func NewResponseWithGobData(c context.Context, data interface{}) Response {
var w bytes.Buffer
encoder := gob.NewEncoder(&w)
if err := encoder.Encode(data); err != nil {
return Err(CodeInternalSetting, "Failed to encode response content", err)
return ErrWithDetails(c, CodeInternalSetting, "Failed to encode response content", err)
}
return Response{Data: w.Bytes()}