修复parse_body相关BUG
This commit is contained in:
@ -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, ";")
|
||||
|
@ -141,13 +141,8 @@ func (wh *wrapperHandle) GetDomain(ctx *gin.Context) string {
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 11:25 2024/7/26
|
||||
func (wh *wrapperHandle) ParseBody(ctx *gin.Context) map[string]any {
|
||||
body := map[string]any{}
|
||||
if _, err := parse_body.Execute(ctx, &body); nil != err {
|
||||
return map[string]any{}
|
||||
}
|
||||
|
||||
return body
|
||||
func (wh *wrapperHandle) ParseBody(ctx *gin.Context) (map[string]any, error) {
|
||||
return parse_body.ExecuteForMap(ctx)
|
||||
}
|
||||
|
||||
// GetResponseBody 获取响应body
|
||||
|
Reference in New Issue
Block a user