Documentation
¶
Overview ¶
Package helper for handling response to client
Index ¶
- func APIErrorResponse(c *gin.Context, statusCode int, err interface{})
- func APIResponse(c *gin.Context, statusCode int, message string, data interface{})
- func CheckPasswordHash(password, hash string) bool
- func EmailIsValid(email string) (isValid bool)
- func GenerateSecureKey(length int) (string, error)
- func HashPassword(password string) (hashed string, err error)
- func PasswordTooShort(password string) (isPasswordtooShort bool)
- func ValidationError(err error) (eMessage *[]string)
- type Error
- type ErrorResponse
- type Response
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func APIErrorResponse ¶
APIErrorResponse will send JSON response with error value to the client
func APIResponse ¶
APIResponse will send JSON response to the client and some additional detail
func CheckPasswordHash ¶
CheckPasswordHash will compare 'hashed' password with the 'input' password
func EmailIsValid ¶
EmailIsValid will check whether given email was valid
func GenerateSecureKey ¶
GenerateSecureKey will create 'Secure Key' with given length
func HashPassword ¶
HashPassword will generated hashed password so it wont easily be roken by unauthorized person
func PasswordTooShort ¶
PasswordTooShort will check whether password length is not match the minimum password lenght for the user account
func ValidationError ¶
ValidationError is a 'Request' error detail generator it will break given error value into detailed error message so we know which field is the cause of error upon handling request
Types ¶
type Error ¶
type Error struct { ErrCode uint `json:"code"` Message string `json:"message,omitempty"` Error error `json:"error"` }
Error is custom dbError struct
type ErrorResponse ¶
type ErrorResponse struct { Status int `json:"status"` Method string `json:"method"` Error interface{} `json:"error"` }
ErrorResponse is a response that containing error Details of the error shoul not be technical as it will be sent to the user