Documentation ¶
Index ¶
- func Send(r *Request) (httpCode *int, err error)
- type Config
- func (c *Config) Validate() (validateErr error)
- func (c *Config) WithCACert(cert *x509.Certificate) *Config
- func (c *Config) WithCACertPool(cp *x509.CertPool) *Config
- func (c *Config) WithCAFilePath(caFilePath string) *Config
- func (c *Config) WithEndPoint(e string) *Config
- func (c *Config) WithHTTPClient(client http.Client) *Config
- func (c *Config) WithPassword(p string) *Config
- func (c *Config) WithUserId(u string) *Config
- type Operation
- func (o *Operation) WithBodyDataByteArray(d []byte) *Operation
- func (o *Operation) WithBodyDataString(d string) *Operation
- func (o *Operation) WithBodyDataStruct(d interface{}) *Operation
- func (o *Operation) WithBodyDataURLValues(d url.Values) *Operation
- func (o *Operation) WithPath(p string) *Operation
- func (o *Operation) WithQueryDataString(d string) *Operation
- func (o *Operation) WithQueryDataURLValues(d url.Values) *Operation
- func (o *Operation) WithResponseTarget(v interface{}) *Operation
- type Request
- type RequestBuilder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct { UserId *string `json:"UserId,omitempty"` Password *string `json:"Password,omitempty"` EndPoint *string TrustCACert *string HTTPClient *http.Client `json:"-"` // contains filtered or unexported fields }
A Config specifies the details needed to connect to a ReST service
func (*Config) WithCACert ¶
func (c *Config) WithCACert(cert *x509.Certificate) *Config
Add a trusted x509 certificate to the configuration. If the ReST service implements TLS/SSL then certificates signed by this CA certificate will be trusted.
func (*Config) WithCACertPool ¶
Add a trusted x509 certificate pool to the configuration. If the ReST service implements TLS/SSL then certificates signed by CA certificates in this pool will be trusted.
func (*Config) WithCAFilePath ¶
Add a trusted x509 certificate to the configuration by specifying a path to a PEM format certificate file. If the ReST service implements TLS/SSL then certificates signed by this CA certificate will be trusted.
func (*Config) WithEndPoint ¶
Specify the URL endpoint of the ReST service in the form http(s)://hostname:port
func (*Config) WithHTTPClient ¶
Override with a specific http.Client to be used for the connection to the ReST service.
func (*Config) WithPassword ¶
Add a password to the config for basic authentication to the ReST service
func (*Config) WithUserId ¶
Add a user ID to the config for basic authentication to the ReST service
type Operation ¶
type Operation struct {
// contains filtered or unexported fields
}
An Operation is the ReST service API operation to be made. It encapsulates the HTTP method to be used, the path to be called and data to be sent, both post and query string data. It also contains a point to a struct that will be the target to hold any response data from the ReST service.
func NewGetOperation ¶
func NewGetOperation() (o *Operation)
Create an Operation that uses the GET verb against the ReST service.
func NewPatchOperation ¶
func NewPatchOperation() (o *Operation)
Create an Operation that uses the PATCH verb against the ReST service.
func NewPostOperation ¶
func NewPostOperation() (o *Operation)
Create an Operation that uses the POST verb against the ReST service.
func NewPutOperation ¶
func NewPutOperation() (o *Operation)
Create an Operation that uses the PUT verb against the ReST service.
func (*Operation) WithBodyDataByteArray ¶
Add some post data to the Operation by providing a byte array
func (*Operation) WithBodyDataString ¶
Add some post data to the Operation by providing a string
func (*Operation) WithBodyDataStruct ¶
Add some post data to the Operation by providing a struct instance that will be marshaled into JSON
func (*Operation) WithBodyDataURLValues ¶
Add some post data to the Operation by providing a url.Values type
func (*Operation) WithQueryDataString ¶
Add data to the query string of the Operation. This method is used to define this using a string. The string will need to be appropriately URL encoded
func (*Operation) WithQueryDataURLValues ¶
Add data to the query string of the Operation. This method is used to define this using a url.Values type.
func (*Operation) WithResponseTarget ¶
Define the pointer to a struct that will be used to hold the response data from the ReST call. When the request is sent to the ReST service any response will be marshalled into this struct.
type Request ¶
type Request struct { Config *Config Operation *Operation HTTPRequest *http.Request HTTPResponse *http.Response StatusCode int }
A Request encapsulates the Config (how to connect to the ReST service) with the Operation (what to request)