client

package
v0.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 1, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetNextIP

func GetNextIP(ip *net.IP, inc uint) *net.IP

GetNextIP() returns the next IP address, but does not account for net masks.

func LoadCertificateFromPath added in v0.3.0

func LoadCertificateFromPath(client Client, path string) error

func LoadCertificateFromPool added in v0.3.0

func LoadCertificateFromPool(client Client, certPool *x509.CertPool) error

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

type DefaultClient struct {
	*http.Client
}

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

type HTTPHeader map[string]string

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 Option

type Option[T Client] func(client *T)

type SmdClient

type SmdClient struct {
	*http.Client
	URI   string
	Xname string
}

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.

func (*SmdClient) GetInternalClient added in v0.1.5

func (c *SmdClient) GetInternalClient() *http.Client

func (*SmdClient) Init added in v0.1.5

func (c *SmdClient) Init()

func (*SmdClient) Name

func (c *SmdClient) Name() string

func (*SmdClient) RootEndpoint

func (c *SmdClient) RootEndpoint(endpoint string) string

func (*SmdClient) SetXnameFromJSON added in v0.3.0

func (c *SmdClient) SetXnameFromJSON(contents []byte, key string) error

func (*SmdClient) Update

func (c *SmdClient) Update(data HTTPBody, headers HTTPHeader) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL