Documentation
¶
Index ¶
- Constants
- func BadInputs(w http.ResponseWriter, message string, code string, field string)
- func CloseBody(body io.ReadCloser)
- func ErrorJson(w http.ResponseWriter, e *Error, httpStatusCode int)
- func Json(w http.ResponseWriter, r *http.Request, data interface{})
- func JsonWithStatus(w http.ResponseWriter, r *http.Request, data interface{}, statusCode int)
- func TimeJson(t time.Time) string
- func WarnJson(w http.ResponseWriter, e *Error, httpStatusCode int)
- type Error
- type ErrorDetail
Constants ¶
View Source
const ( PANIC = "Panic" NotFound = "NotFound" MethodNotAllowed = "MethodNotAllowed" InvalidJson = "InvalidJson" JsonEncodeFailed = "JsonEncodeFailed" SystemError = "SystemError" EncryptionFailed = "EncryptionFailed" TokenCreationFailed = "TokenCreationFailed" AccountExists = "AccountExists" UpdateFailed = "UpdateFailed" AccountCreateFailed = "AccountCreateFailed" ProfileCreateFailed = "ProfileCreateFailed" EmailExistsInAccount = "EmailExistsInAccount" ProfileNotFound = "ProfileNotFound" InvalidEmail = "InvalidEmail" InvalidForgotToken = "InvalidForgotToken" InvalidPassword = "InvalidPassword" PasswordMismatch = "PasswordMismatch" InvalidField = "InvalidField" ProfileLocked = "ProfileLocked" NotAuthorized = "NotAuthorized" IncorrectPassword = "IncorrectPassword" InvalidToken = "InvalidToken" TokenExpired = "TokenExpired" MissingToken = "MissingToken" ProfileInactive = "ProfileInactive" AccountInactive = "AccountInactive" MissingField = "MissingField" FieldSize = "FieldSize" InvalidWeekStart = "InvalidWeekStart" InvalidRole = "InvalidRole" InvalidTimezone = "InvalidTimezone" InvalidClient = "InvalidClient" InvalidTask = "InvalidTask" InvalidProject = "InvalidProject" )
Error Codes
View Source
const ( SuccessStatus = "success" ErrorStatus = "error" )
Variables ¶
This section is empty.
Functions ¶
func CloseBody ¶
func CloseBody(body io.ReadCloser)
func ErrorJson ¶
func ErrorJson(w http.ResponseWriter, e *Error, httpStatusCode int)
Writes an error JSON response
func Json ¶
func Json(w http.ResponseWriter, r *http.Request, data interface{})
Writes a successful JSON response and marshals the value type as the data element
func JsonWithStatus ¶
func JsonWithStatus(w http.ResponseWriter, r *http.Request, data interface{}, statusCode int)
Writes a JSON response with the given header status code and marshals the value type as the data element
Types ¶
type Error ¶
func NewError ¶
func NewError(errorDetail interface{}, message string, code string, details ...ErrorDetail) *Error
Standardize the creation and reporting of errors using a generic Err type
func NewFieldError ¶
func (*Error) MarshalJSON ¶
type ErrorDetail ¶
type ErrorDetail struct { Key string Value interface{} }
func NewErrorDetail ¶
func NewErrorDetail(key string, value interface{}) ErrorDetail
Click to show internal directories.
Click to hide internal directories.