http

package
v1.203.0 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package http is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get(ctx context.Context, url string, client Client) ([]byte, error)

Get performs an HTTP GET request with context using the provided client.

func GetGitHubTokenFromEnv added in v1.203.0

func GetGitHubTokenFromEnv() string

GetGitHubTokenFromEnv retrieves GitHub token from the global configuration. This function respects the standard Atmos precedence order:

  1. --github-token CLI flag (via viper, only available for toolchain commands)
  2. ATMOS_GITHUB_TOKEN environment variable
  3. GITHUB_TOKEN environment variable

The viper binding is configured in cmd/toolchain/toolchain.go for toolchain commands. For non-toolchain commands, we fall back to direct environment variable lookup.

Types

type Client

type Client interface {
	// Do performs an HTTP request and returns the response.
	Do(req *http.Request) (*http.Response, error)
}

Client defines the interface for making HTTP requests. This interface allows for easy mocking in tests.

type ClientOption added in v1.203.0

type ClientOption func(*DefaultClient)

ClientOption is a functional option for configuring the DefaultClient.

func WithGitHubToken added in v1.203.0

func WithGitHubToken(token string) ClientOption

WithGitHubToken sets the GitHub token for authenticated requests. Wraps the existing transport instead of replacing it to allow composition with WithTransport.

func WithTimeout added in v1.203.0

func WithTimeout(timeout time.Duration) ClientOption

WithTimeout sets the HTTP client timeout.

func WithTransport added in v1.203.0

func WithTransport(transport http.RoundTripper) ClientOption

WithTransport sets a custom HTTP transport.

type DefaultClient

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

DefaultClient is the default HTTP client implementation.

func NewDefaultClient

func NewDefaultClient(opts ...ClientOption) *DefaultClient

NewDefaultClient creates a new DefaultClient with optional configuration.

func (*DefaultClient) Do

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

Do implements Client.Do.

type GitHubAuthenticatedTransport added in v1.203.0

type GitHubAuthenticatedTransport struct {
	Base        http.RoundTripper
	GitHubToken string
}

GitHubAuthenticatedTransport wraps an http.Transport to add GitHub token authentication.

func (*GitHubAuthenticatedTransport) RoundTrip added in v1.203.0

RoundTrip implements http.RoundTripper interface.

type MockClient

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

MockClient is a mock of Client interface.

func NewMockClient

func NewMockClient(ctrl *gomock.Controller) *MockClient

NewMockClient creates a new mock instance.

func (*MockClient) Do

func (m *MockClient) Do(req *http.Request) (*http.Response, error)

Do mocks base method.

func (*MockClient) EXPECT

func (m *MockClient) EXPECT() *MockClientMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

type MockClientMockRecorder

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

MockClientMockRecorder is the mock recorder for MockClient.

func (*MockClientMockRecorder) Do

func (mr *MockClientMockRecorder) Do(req any) *gomock.Call

Do indicates an expected call of Do.

Jump to

Keyboard shortcuts

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