修复相应类型设置错误的BUG
This commit is contained in:
parent
0bd02dbd08
commit
146fbaf878
@ -95,7 +95,7 @@ func Send(ctx *gin.Context, code any, httpCode int, data any, responseOption *de
|
|||||||
responseContentType := getResponseDataType(responseOption.ContentType)
|
responseContentType := getResponseDataType(responseOption.ContentType)
|
||||||
responseInstance, _ := wrapper.NewJson(serialize.JSON.MarshalForStringIgnoreError(responseException.GetData()), &wrapper.Option{XmlName: responseOption.XmlName})
|
responseInstance, _ := wrapper.NewJson(serialize.JSON.MarshalForStringIgnoreError(responseException.GetData()), &wrapper.Option{XmlName: responseOption.XmlName})
|
||||||
finalResponseData, _ := responseInstance.Marshal(responseContentType)
|
finalResponseData, _ := responseInstance.Marshal(responseContentType)
|
||||||
ctx.Data(responseException.GetHttpCode(), responseContentType, finalResponseData)
|
ctx.Data(responseException.GetHttpCode(), responseOption.ContentType, finalResponseData)
|
||||||
}
|
}
|
||||||
|
|
||||||
// getResponseDataType 获取相应数据类型
|
// getResponseDataType 获取相应数据类型
|
||||||
@ -138,7 +138,7 @@ func SendWithStatusOK(ctx *gin.Context, code any, data any) {
|
|||||||
// Author : go_developer@163.com<白茶清欢>
|
// Author : go_developer@163.com<白茶清欢>
|
||||||
//
|
//
|
||||||
// Date : 13:08 2022/6/26
|
// Date : 13:08 2022/6/26
|
||||||
func SendWithException(ctx *gin.Context, e exception.IException, data map[string]any) {
|
func SendWithException(ctx *gin.Context, e exception.IException, data map[string]any, responseOption *define.ResponseOption) {
|
||||||
if nil == e {
|
if nil == e {
|
||||||
e = exception.NewSuccess(data)
|
e = exception.NewSuccess(data)
|
||||||
}
|
}
|
||||||
@ -152,7 +152,7 @@ func SendWithException(ctx *gin.Context, e exception.IException, data map[string
|
|||||||
"e_data": e.GetData(),
|
"e_data": e.GetData(),
|
||||||
"u_e_data": data,
|
"u_e_data": data,
|
||||||
}
|
}
|
||||||
Send(ctx, e.GetCode(), e.GetHttpCode(), outputData, nil)
|
Send(ctx, e.GetCode(), e.GetHttpCode(), outputData, responseOption)
|
||||||
}
|
}
|
||||||
|
|
||||||
// JSON ctx.JSON 的平替, 增加了数据是否已相应的标识
|
// JSON ctx.JSON 的平替, 增加了数据是否已相应的标识
|
||||||
|
@ -44,7 +44,9 @@ func RequestHandler(uriCfg UriConfig) gin.HandlerFunc {
|
|||||||
// 格式化验证错误的信息
|
// 格式化验证错误的信息
|
||||||
err = GetValidateErr(formValue, err)
|
err = GetValidateErr(formValue, err)
|
||||||
e = exception.NewFromError(400, err)
|
e = exception.NewFromError(400, err)
|
||||||
response.SendWithException(ctx, e, nil)
|
response.SendWithException(ctx, e, nil, &define.ResponseOption{
|
||||||
|
ContentType: "application/json;charset=utf-8",
|
||||||
|
})
|
||||||
ctx.Abort()
|
ctx.Abort()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -97,7 +99,7 @@ func RequestHandler(uriCfg UriConfig) gin.HandlerFunc {
|
|||||||
if resList[1].IsNil() {
|
if resList[1].IsNil() {
|
||||||
// 请求成功
|
// 请求成功
|
||||||
isSuccess = true
|
isSuccess = true
|
||||||
response.Success(ctx, resList[0].Interface())
|
response.SuccessWithExtension(ctx, resList[0].Interface(), &define.ResponseOption{ContentType: "application/json;charset=utf-8"})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 请求失败
|
// 请求失败
|
||||||
@ -110,7 +112,9 @@ func RequestHandler(uriCfg UriConfig) gin.HandlerFunc {
|
|||||||
"err": resList[1].Interface(),
|
"err": resList[1].Interface(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
response.SendWithException(ctx, e, nil)
|
response.SendWithException(ctx, e, nil, &define.ResponseOption{
|
||||||
|
ContentType: "application/json;charset=utf-8",
|
||||||
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user