reCoreD-UI/server/response.go

24 lines
416 B
Go
Raw Normal View History

2024-04-03 14:37:15 +00:00
package server
import (
"net/http"
"github.com/gin-gonic/gin"
2024-04-07 02:08:02 +00:00
"github.com/sirupsen/logrus"
2024-04-03 14:37:15 +00:00
)
type Response struct {
Succeed bool `json:"succeed"`
Message string `json:"message"`
Data interface{} `json:"data"`
}
func errorHandler(c *gin.Context, err error) {
2024-04-07 02:08:02 +00:00
logrus.Error(err)
2024-04-03 14:37:15 +00:00
c.JSON(http.StatusInternalServerError, Response{
Succeed: false,
Message: err.Error(),
Data: nil,
})
}