mirror of https://gitee.com/topnuomi/goweb
30 lines
548 B
Go
30 lines
548 B
Go
package response
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
type Struct struct {
|
|
Code int `json:"code"`
|
|
Message string `json:"message"`
|
|
Data interface{} `json:"data"`
|
|
}
|
|
|
|
func Ok(ctx *gin.Context, resp Struct) {
|
|
ctx.JSON(http.StatusOK, resp)
|
|
}
|
|
|
|
func NotModified(ctx *gin.Context, resp Struct) {
|
|
ctx.JSON(http.StatusNotModified, resp)
|
|
}
|
|
|
|
func NotFound(ctx *gin.Context, resp Struct) {
|
|
ctx.JSON(http.StatusNotFound, resp)
|
|
}
|
|
|
|
func BadRequest(ctx *gin.Context, resp Struct) {
|
|
ctx.JSON(http.StatusBadRequest, resp)
|
|
}
|