Documentation
¶
Index ¶
- Constants
- func AppendError(value string, err error) string
- func BuildHTTPError(err error, msg string) *echo.HTTPError
- func CheckLocalhostURL(u string) error
- func ClientWithJSON(j string, code int) *http.Client
- func ClientWithToken(accessToken string) *http.Client
- func Error(value string, inner error) error
- func GetStatusCode(err error) int
- func GetValueString(value, def string) string
- func Sanitize(m map[string]string) map[string]string
- func ValidateStruct(s interface{}, m map[string]string) error
- type TransportFunc
Constants ¶
const (
// Empty is empty/blank string.
Empty = ""
)
Variables ¶
This section is empty.
Functions ¶
func AppendError ¶
AppendError appends the error message to the value.
func BuildHTTPError ¶
BuildHTTPError converts error object to http error by checking internal http status code.
func CheckLocalhostURL ¶
CheckLocalhostURL validates the url. The url must be a valid and localhost url.
func ClientWithJSON ¶
ClientWithJSON creates a new http client. It has an internal transport function which build custom response with the specified json and http status code. It is useful for testing http calls.
func ClientWithToken ¶
ClientWithToken creates a new http client and injects the access token in the authorization header.
func GetStatusCode ¶
GetStatusCode extracts http status code from the error object.
func GetValueString ¶
GetValueString returns the specified value, but if the specified value is empty, it returns the default value.
func Sanitize ¶
Sanitize removes the leading and trailing spaces from each map items. If the map key contains only spaces, the key/value pair is removed from the map.
func ValidateStruct ¶
ValidateStruct checks all validation rules on struct fields. It returns error on any validation failure.
Types ¶
type TransportFunc ¶
TransportFunc is used to customize the http client's transport layer. User can inject a hook function to change the request and response params.