mg-transport-core/core/error.go
Alex Lushpai 34cba277b9 init
2019-09-04 15:22:27 +03:00

18 lines
355 B
Go

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,
}
}