Documentation
¶
Index ¶
- func GetNextIP(ip *net.IP, inc uint) *net.IP
- func LoadCertificateFromPath(client Client, path string) error
- func LoadCertificateFromPool(client Client, certPool *x509.CertPool) error
- type Client
- type DefaultClient
- type HTTPBody
- type HTTPHeader
- type Option
- type SmdClient
- func (c *SmdClient) Add(data HTTPBody, headers HTTPHeader) error
- func (c *SmdClient) GetInternalClient() *http.Client
- func (c *SmdClient) Init()
- func (c *SmdClient) Name() string
- func (c *SmdClient) RootEndpoint(endpoint string) string
- func (c *SmdClient) SetXnameFromJSON(contents []byte, key string) error
- func (c *SmdClient) Update(data HTTPBody, headers HTTPHeader) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadCertificateFromPath ¶ added in v0.3.0
Types ¶
type Client ¶
type Client interface {
Init()
Name() string
RootEndpoint(endpoint string) string
GetInternalClient() *http.Client
// functions needed to make request
Add(data HTTPBody, headers HTTPHeader) error
Update(data HTTPBody, headers HTTPHeader) error
}
The 'Client' struct is a wrapper around the default http.Client that provides an extended API to work with functional options. It also provides functions that work with `collect` data.
type DefaultClient ¶ added in v0.3.0
func (*DefaultClient) Add ¶ added in v0.3.0
func (c *DefaultClient) Add(data HTTPBody, headers HTTPHeader) error
Add() is the default function that is called with a client with no implementation. This function will simply make a HTTP request including all the data passed as the first argument with no data processing or manipulation. The function sends the data to a set callback URL (which may be changed to use a configurable value instead).
func (*DefaultClient) Name ¶ added in v0.3.0
func (c *DefaultClient) Name() string
func (*DefaultClient) Post ¶ added in v0.3.0
func (c *DefaultClient) Post(url string, data map[string]any, header HTTPHeader) (*http.Response, HTTPBody, error)
Post() is a simplified wrapper function that packages all of the that marshals a mapper into a JSON-formatted byte array, and then performs a request to the specified URL.
func (*DefaultClient) Update ¶ added in v0.3.0
func (c *DefaultClient) Update(data HTTPBody, headers HTTPHeader) error
type HTTPBody ¶
type HTTPBody []byte
func MakeRequest ¶
func MakeRequest(client *http.Client, url string, httpMethod string, body HTTPBody, header HTTPHeader) (*http.Response, HTTPBody, error)
MakeRequest() is a wrapper function that condenses simple HTTP requests done to a single call. It expects an optional HTTP client, URL, HTTP method, request body, and request headers. This function is useful when making many requests where only these few arguments are changing.
Returns a HTTP response object, response body as byte array, and any error that may have occurred with making the request.
type HTTPHeader ¶
HTTP aliases for readibility
func (HTTPHeader) Authorization ¶
func (h HTTPHeader) Authorization(accessToken string) HTTPHeader
func (HTTPHeader) ContentType ¶
func (h HTTPHeader) ContentType(contentType string) HTTPHeader
type SmdClient ¶
func NewSmdClient ¶ added in v0.3.0
func NewSmdClient() *SmdClient
func (*SmdClient) Add ¶
func (c *SmdClient) Add(data HTTPBody, headers HTTPHeader) error
Add() has a similar function definition to that of the default implementation, but also allows further customization and data/header manipulation that would be specific and/or unique to SMD's API.