Documentation
¶
Overview ¶
Package apihelper automate construction of http response
Index ¶
- func BuildChatfuelResponseError(err *servicehelper.Error) (int, gin.H)
- func GetBoolQueryParam(c *gin.Context, value *bool, queryParam string, defaultValue bool) bool
- func GetDateQueryParam(c *gin.Context, queryParam string, dateLayout string, defaultValue string) (string, bool)
- func GetStringQueryParam(c *gin.Context, queryParam string, acceptedValues []string, ...) (string, bool)
- type ApiError
- type ApiErrors
- type Error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildChatfuelResponseError ¶
func BuildChatfuelResponseError(err *servicehelper.Error) (int, gin.H)
BuildChatfuelResponseError apply the right status to the http response and build the error JSON object for Chatfuel
func GetBoolQueryParam ¶
GetBoolQueryParam allow to retrieve a boolean query parameter. It takes the gin context as param to build error if queryParam is not formatted correctly and a default value to set value if the parameter is optional and not set.
func GetDateQueryParam ¶
func GetDateQueryParam(c *gin.Context, queryParam string, dateLayout string, defaultValue string) (string, bool)
GetDateQueryParam allow to retrieve a date (as a string) query parameter. It takes the gin context as param to build error if queryParam is not formatted correctly and a default value to set value if the parameter is optional and not set. The dateLayout will define if the date is valid or not
func GetStringQueryParam ¶
func GetStringQueryParam(c *gin.Context, queryParam string, acceptedValues []string, defaultValue string) (string, bool)
GetStringQueryParam allow to retrieve a string query parameter. It takes the gin context as param to build error if queryParam is not formatted correctly and a default value to set value if the parameter is optional and not set. the accepted values list will define if the value is valid or not
Types ¶
type ApiErrors ¶
type ApiErrors struct {
Errors []ApiError
}
ApiErrors carry the list of errors returned by the API from a request
func BuildRequestError ¶
BuildRequestError build a usable JSON error object from an error string generated by the structure validator
func BuildResponseError ¶
func BuildResponseError(err *servicehelper.Error) (status int, apiErrors ApiErrors)
BuildResponseError apply the right status to the http response and build the error JSON object