读取结果增加缓存
This commit is contained in:
parent
927870b11a
commit
ecaf448100
@ -59,10 +59,24 @@ func Execute(ctx *gin.Context, receiver any) ([]byte, error) {
|
||||
if _, exist := requestBodyParseAdaptorTable[contentType]; !exist {
|
||||
return nil, errors.New(contentType + " : adaptor not found")
|
||||
}
|
||||
bodyData, err := ReadBody(ctx)
|
||||
if nil != err {
|
||||
return nil, err
|
||||
var (
|
||||
bodyData []byte
|
||||
err error
|
||||
exist bool
|
||||
body any
|
||||
)
|
||||
|
||||
bodyKey := "_body_read_result"
|
||||
if body, exist = ctx.Get(bodyKey); exist && nil != body {
|
||||
bodyData = body.([]byte)
|
||||
} else {
|
||||
if bodyData, err = ReadBody(ctx); nil != err {
|
||||
return nil, err
|
||||
}
|
||||
// 设置读取结果
|
||||
ctx.Set(bodyKey, bodyData)
|
||||
}
|
||||
|
||||
if err = requestBodyParseAdaptorTable[contentType].Unmarshal(bodyData, receiver); nil != err {
|
||||
return nil, err
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user