go17/book/response/response.go

16 lines
264 B
Go
Raw Normal View History

2024-11-23 10:55:52 +08:00
package response
import (
"net/http"
"github.com/gin-gonic/gin"
)
func Failed(ctx *gin.Context, err error) {
ctx.JSON(http.StatusBadRequest, gin.H{"code": 0, "msg": err.Error()})
}
func Success(ctx *gin.Context, data any) {
ctx.JSON(http.StatusOK, data)
}