Documentation
¶
Index ¶
- Variables
- func Auth(request *wedeploy.WeDeploy)
- func AuthGet(path string, data interface{}) error
- func AuthGetOrExit(path string, data interface{})
- func DecodeJSON(request *wedeploy.WeDeploy, data interface{}) error
- func DecodeJSONOrExit(request *wedeploy.WeDeploy, data interface{})
- func EncodeJSON(data interface{}) (*bytes.Reader, error)
- func ParamsFromJSON(request *wedeploy.WeDeploy, data interface{})
- func SetBody(request *wedeploy.WeDeploy, data interface{}) error
- func URL(paths ...string) *wedeploy.WeDeploy
- func Validate(request *wedeploy.WeDeploy, err error) error
- func ValidateOrExit(request *wedeploy.WeDeploy, err error)
- type APIFault
- type APIFaultError
- type APIFaultErrors
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidContentType is used when the content-type is not application/json ErrInvalidContentType = errors.New("Can only decode data for application/json") // ErrExtractingParams is used when query string params fail due to unrecognized type ErrExtractingParams = errors.New("Can only extract query string params from flat objects") )
var DefaultToken = "1"
DefaultToken for the API server
Functions ¶
func Auth ¶
func Auth(request *wedeploy.WeDeploy)
Auth a WeDeploy request with the global authentication data
func AuthGetOrExit ¶
func AuthGetOrExit(path string, data interface{})
AuthGetOrExit is like AuthGet, but exits on failure
func DecodeJSON ¶
func DecodeJSON(request *wedeploy.WeDeploy, data interface{}) error
DecodeJSON decodes a JSON response
func DecodeJSONOrExit ¶
func DecodeJSONOrExit(request *wedeploy.WeDeploy, data interface{})
DecodeJSONOrExit decodes a JSON response or exits the process on error
func EncodeJSON ¶
EncodeJSON encodes a object using its JSON annotations map and creates a reader that can be used as body for requests, for example
func ParamsFromJSON ¶
func ParamsFromJSON(request *wedeploy.WeDeploy, data interface{})
ParamsFromJSON creates query string params from a flat object with JSON tags
func SetBody ¶
func SetBody(request *wedeploy.WeDeploy, data interface{}) error
SetBody sets the body of a request with the JSON encoded from an object
func ValidateOrExit ¶
func ValidateOrExit(request *wedeploy.WeDeploy, err error)
ValidateOrExit validates a request or exits the process on error
Types ¶
type APIFault ¶
type APIFault struct {
Method string
URL string
Code int `json:"code"`
Message string `json:"message"`
Errors APIFaultErrors `json:"errors"`
}
APIFault is sent by the server when errors happen Method and URL MUST NOT have JSON tags
type APIFaultError ¶
APIFaultError is the error structure for the errors described by a fault
type APIFaultErrors ¶
type APIFaultErrors []APIFaultError
APIFaultErrors is the array of APIFaultError