apiclient

package
v0.1.0-beta.41 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("resource not found")

Functions

This section is empty.

Types

type APIClient

type APIClient struct {
	// contains filtered or unexported fields
}

APIClient handles communication with the haloy API

func New

func New(url, token string) (*APIClient, error)

func NewWithTimeout

func NewWithTimeout(url, token string, timeout time.Duration) (*APIClient, error)

func (*APIClient) Do

func (c *APIClient) Do(req *http.Request) (*http.Response, error)

Do executes a request using the client's http.Client. Use with NewRequest for custom requests that don't fit Get/Post patterns.

func (*APIClient) Get

func (c *APIClient) Get(ctx context.Context, path string, v any) error

func (*APIClient) HealthCheck

func (c *APIClient) HealthCheck(ctx context.Context) error

func (*APIClient) NewRequest

func (c *APIClient) NewRequest(ctx context.Context, method, path string, body io.Reader) (*http.Request, error)

NewRequest creates an authenticated request with the base URL and auth header set. Callers can customize the request (add headers, etc.) before calling Do.

func (*APIClient) Post

func (c *APIClient) Post(ctx context.Context, path string, request, response any) error

func (*APIClient) PostFile

func (c *APIClient) PostFile(ctx context.Context, path, fieldName, filePath string) error

PostFile uploads a file using multipart form data

func (*APIClient) Stream

func (c *APIClient) Stream(ctx context.Context, path string, handler func(data string) bool) error

Generic streaming method that handles any SSE endpoint

Jump to

Keyboard shortcuts

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