response fix
This commit is contained in:
parent
a128eb8461
commit
629ec74be6
|
@ -16,6 +16,7 @@ type Reply struct {
|
|||
func (reply *Reply) Success(ctx *gin.Context, data any) {
|
||||
reply.Code = 200
|
||||
reply.Data = data
|
||||
reply.Msg = ""
|
||||
if data == nil {
|
||||
reply.Data = ""
|
||||
}
|
||||
|
@ -23,12 +24,12 @@ func (reply *Reply) Success(ctx *gin.Context, data any) {
|
|||
}
|
||||
func (reply *Reply) Error(ctx *gin.Context, err error) {
|
||||
reply.Code = 500
|
||||
reply.Data = ""
|
||||
// Status code defaults to 500
|
||||
e, ok := status.FromError(err)
|
||||
if ok {
|
||||
reply.Code = int(e.Code())
|
||||
}
|
||||
|
||||
reply.Msg = e.Message()
|
||||
|
||||
// Send error
|
||||
|
|
Loading…
Reference in New Issue