Documentation ¶
Index ¶
- Constants
- func CheckParams(body interface{}, params []string) []string
- func CheckParamsStruc(body interface{}) []string
- func CreateMsg(status string, dataMsg interface{}, errMsg interface{}) ([]byte, error)
- func Error(w http.ResponseWriter, newErr error, code int)
- func Readbody(w http.ResponseWriter, r *http.Request) []byte
- func WriteMsg(w http.ResponseWriter, dataMsg interface{}, errMsg interface{})
- type ErrorMsg
Constants ¶
View Source
const ( InvalidParameters int = 4001 InvalidJSON int = 4002 CredentialsExist int = 6001 CredentialsNotFound int = 6002 TokenExpired int = 6003 UserTokenNotFound int = 6004 )
Const for custom errors
Variables ¶
This section is empty.
Functions ¶
func CheckParams ¶
CheckParams checks if all listed params in params are set in body struc
func CheckParamsStruc ¶
func CheckParamsStruc(body interface{}) []string
CheckParamsStruc checks if all parameters in the structure are set
func Readbody ¶
func Readbody(w http.ResponseWriter, r *http.Request) []byte
Readbody reads body to byte array and if failed return error 500
func WriteMsg ¶
func WriteMsg(w http.ResponseWriter, dataMsg interface{}, errMsg interface{})
WriteMsg writes a unified JSON structure to the client
Types ¶
type ErrorMsg ¶
type ErrorMsg struct { Code int `json:"code"` CustomCode int `json:"custom_code"` ErrorType string `json:"type"` ErrorParam []string `json:"param"` Message string `json:"message"` }
ErrorMsg the message to send to the client if an error occures
func CreateErrorMsg ¶
CreateErrorMsg create error message with given cusCode and params
Click to show internal directories.
Click to hide internal directories.