32 lines
742 B
Go
32 lines
742 B
Go
package response
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func Fail(c *gin.Context, status int, code int, message string) {
|
|
c.JSON(status, body(c, code, message, nil))
|
|
}
|
|
|
|
func BadRequest(c *gin.Context, message string) {
|
|
Fail(c, http.StatusBadRequest, CodeBadRequest, message)
|
|
}
|
|
|
|
func Unauthorized(c *gin.Context, message string) {
|
|
Fail(c, http.StatusUnauthorized, CodeUnauthorized, message)
|
|
}
|
|
|
|
func Forbidden(c *gin.Context, message string) {
|
|
Fail(c, http.StatusForbidden, CodeForbidden, message)
|
|
}
|
|
|
|
func NotFound(c *gin.Context, message string) {
|
|
Fail(c, http.StatusNotFound, CodeNotFound, message)
|
|
}
|
|
|
|
func ServerError(c *gin.Context, message string) {
|
|
Fail(c, http.StatusInternalServerError, CodeServerError, message)
|
|
}
|