Documentation ¶
Overview ¶
Package utils contains helper functions
Index ¶
- func GenerateEtag() (string, error)
- func GenerateID() string
- func GetValueFromVars(vars map[string]string, key string) (string, error)
- func WriteErrorMessage(w http.ResponseWriter, req *http.Request, status int, message string)
- func WriteJSON(w http.ResponseWriter, r *http.Request, data interface{})
- func WriteJSONWithStatus(w http.ResponseWriter, r *http.Request, data interface{}, status int)
- func WriteResponseMessage(w http.ResponseWriter, req *http.Request, status int, message string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateEtag ¶
GenerateEtag generates a random etag which is generated on every write action
func GenerateID ¶
func GenerateID() string
GenerateID generates a string to be used as the resource ID
func GetValueFromVars ¶
GetValueFromVars returns a specified value from the supplied request vars.
func WriteErrorMessage ¶
WriteErrorMessage logs an error and adds it to the response, along with the supplied status
func WriteJSON ¶
func WriteJSON(w http.ResponseWriter, r *http.Request, data interface{})
WriteJSON writes the interface as a json string with status of 200.
func WriteJSONWithStatus ¶
func WriteJSONWithStatus(w http.ResponseWriter, r *http.Request, data interface{}, status int)
WriteJSONWithStatus writes the interface as a json string with the supplied status.
func WriteResponseMessage ¶
WriteResponseMessage writes a supplied message and status to the response, and logs an info message
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.