upstream sync
This commit is contained in:
@@ -33,6 +33,18 @@ func ResponseAPIOK(c echo.Context, data interface{}) error {
|
||||
return c.JSON(http.StatusOK, data)
|
||||
}
|
||||
|
||||
// ResponseAPIErrorWithData returns a standard API error with additional data to the response
|
||||
func ResponseAPIErrorWithData(c echo.Context, status int, message string, redirect bool, data interface{}) error {
|
||||
returnValue := resultWrapper{
|
||||
Error: true,
|
||||
Message: message,
|
||||
Redirect: redirect,
|
||||
Data: data,
|
||||
}
|
||||
|
||||
return c.JSON(status, returnValue)
|
||||
}
|
||||
|
||||
// ResponseAPIError returns a standard API error to the response
|
||||
func ResponseAPIError(c echo.Context, status int, message string, redirect bool) error {
|
||||
returnValue := resultWrapper{
|
||||
@@ -49,6 +61,11 @@ func ResponseAPIAuthError(c echo.Context, message string, redirect bool) error {
|
||||
return ResponseAPIError(c, http.StatusUnauthorized, message, redirect)
|
||||
}
|
||||
|
||||
// ResponseAPIAuthorizationError returns a standard API auth error to the response
|
||||
func ResponseAPIAuthorizationError(c echo.Context) error {
|
||||
return ResponseAPIError(c, http.StatusForbidden, "Forbidden by controller", false)
|
||||
}
|
||||
|
||||
// ResponseAPIServiceError returns a standard API service unavailable error to the response
|
||||
func ResponseAPIServiceError(c echo.Context, message string) error {
|
||||
return ResponseAPIError(c, http.StatusServiceUnavailable, message, false)
|
||||
@@ -59,6 +76,11 @@ func ResponseAPIValidationError(c echo.Context, message string) error {
|
||||
return ResponseAPIError(c, http.StatusUnprocessableEntity, message, false)
|
||||
}
|
||||
|
||||
// ResponseAPICustomValidationError returns a standard API validation error with custom data to the response
|
||||
func ResponseAPICustomValidationError(c echo.Context, message string, data interface{}) error {
|
||||
return ResponseAPIErrorWithData(c, http.StatusUnprocessableEntity, message, false, data)
|
||||
}
|
||||
|
||||
// ResponseAPIFieldValidationError returns a standard API field validation error to the response
|
||||
func ResponseAPIFieldValidationError(c echo.Context, field string, message string) error {
|
||||
err := errors.NewValidationError(field, message)
|
||||
|
||||
Reference in New Issue
Block a user