httpclient

package
v0.1.0-release Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: Apache-2.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package httpclient implements the low-level HTTP communication for the DevBridge REST API.

It is only for the SDK root package (Go internal mechanism, not importable externally), and handles: request construction and auth headers, error status codes, business error parsing, and request/response logging.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Code    string // error code, e.g. "HD.98320078"
	Message string // error description
}

APIError represents a business error returned by the server.

func (*APIError) Error

func (e *APIError) Error() string

type Client

type Client struct {
	APIKey  string
	BaseURL string
	HTTP    *http.Client
	Logger  *slog.Logger
}

Client sends REST API requests.

func New

func New(apiKey, baseURL string, httpClient *http.Client, logger *slog.Logger) *Client

New creates an HTTP client. When httpClient is nil a default client with a 30s timeout is created; otherwise the caller-provided client is used.

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, path string, result any) error

func (*Client) Do

func (c *Client) Do(ctx context.Context, method, path string, body, result any) error

Do sends an HTTP request and handles the response.

func (*Client) Get

func (c *Client) Get(ctx context.Context, path string, result any) error

func (*Client) Post

func (c *Client) Post(ctx context.Context, path string, body, result any) error

func (*Client) Put

func (c *Client) Put(ctx context.Context, path string, body, result any) error

type UpgradeRequiredError

type UpgradeRequiredError struct {
	Message string
}

UpgradeRequiredError indicates the server rejected the request because the client version is below the server's minimum required version (HTTP 426).

func (*UpgradeRequiredError) Error

func (e *UpgradeRequiredError) Error() string

Jump to

Keyboard shortcuts

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