https

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: May 28, 2026 License: Apache-2.0 Imports: 9 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 https provides a unified HTTP client for making API requests with centralized auth, error handling, and debug logging.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is a unified HTTP client for API requests.

func NewClient

func NewClient(apiKey, baseURL string, log logger.Logger) *Client

NewClient creates a new HTTP client with the given credentials and base URL. The baseURL parameter is the base URL (e.g., "https://api.braintrust.dev" or "https://www.braintrust.dev").

func NewWrappedClient added in v0.0.2

func NewWrappedClient(apiKey, baseURL string, httpClient *http.Client, log logger.Logger) *Client

NewWrappedClient creates a new HTTP client with a custom http.Client. This is useful for tests that need to wrap the HTTP client (e.g., with VCR).

func (*Client) APIKey added in v0.1.0

func (c *Client) APIKey() string

APIKey returns the API key used by this client.

func (*Client) Client added in v0.1.0

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

Client returns the underlying http.Client. This is useful for extracting the client for auth.Session when using VCR.

func (*Client) DELETE

func (c *Client) DELETE(ctx context.Context, path string) (*http.Response, error)

DELETE makes a DELETE request. The path is appended to the base URL (e.g., "/v1/function/123").

func (*Client) GET

func (c *Client) GET(ctx context.Context, path string, params map[string]string) (*http.Response, error)

GET makes a GET request with query parameters. The path is appended to the base URL (e.g., "/v1/project").

func (*Client) POST

func (c *Client) POST(ctx context.Context, path string, body interface{}) (*http.Response, error)

POST makes a POST request with a JSON body. The path is appended to the base URL (e.g., "/api/apikey/login").

type HTTPError added in v0.1.0

type HTTPError struct {
	StatusCode int
	Body       string
	// contains filtered or unexported fields
}

HTTPError represents an HTTP error response with status code.

func (*HTTPError) Error added in v0.1.0

func (e *HTTPError) Error() string

func (*HTTPError) Unwrap added in v0.1.0

func (e *HTTPError) Unwrap() error

Jump to

Keyboard shortcuts

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