mg-transport-core/core/error.go

18 lines
355 B
Go
Raw Normal View History

2019-09-04 15:22:27 +03:00
package core
import "net/http"
// ErrorResponse struct
type ErrorResponse struct {
Error string `json:"error"`
}
// BadRequest returns ErrorResponse with code 400
// Usage (with gin):
// context.JSON(BadRequest("invalid data"))
func BadRequest(error string) (int, interface{}) {
return http.StatusBadRequest, ErrorResponse{
Error: error,
}
}