initial commit example
This commit is contained in:
18
httputil/error.go
Normal file
18
httputil/error.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package httputil
|
||||
|
||||
import "github.com/gin-gonic/gin"
|
||||
|
||||
// NewError example
|
||||
func NewError(ctx *gin.Context, status int, err error) {
|
||||
er := HTTPError{
|
||||
Code: status,
|
||||
Message: err.Error(),
|
||||
}
|
||||
ctx.JSON(status, er)
|
||||
}
|
||||
|
||||
// HTTPError example
|
||||
type HTTPError struct {
|
||||
Code int `json:"code" example:"400"`
|
||||
Message string `json:"message" example:"status bad request"`
|
||||
}
|
||||
Reference in New Issue
Block a user