修复parse_body相关BUG

This commit is contained in:
2025-05-04 14:52:20 +08:00
parent 2aa8e86917
commit 927870b11a
3 changed files with 9 additions and 11 deletions

View File

@ -46,7 +46,7 @@ func Register(requestType string, adaptor abstract.RequestBodyParseAdaptor) {
func Execute(ctx *gin.Context, receiver any) ([]byte, error) {
contentType := strings.ToLower(strings.ReplaceAll(ctx.ContentType(), " ", ""))
if len(contentType) == 0 {
return nil, errors.New("content_type is empty")
return []byte("{}"), nil
}
// 裁剪出真实的类型,之所以截取,是因为 content_type 中可能还包含编码信息, 如 : application/json;chaset=utf8
contentTypeArr := strings.Split(contentType, ";")