Documentation
¶
Overview ¶
Package http provides a common HTTP client with standardized headers and error handling
Index ¶
- type Client
- func (c *Client) Delete(ctx context.Context, endpoint string, v interface{}) error
- func (c *Client) Do(ctx context.Context, method, endpoint string, body interface{}, v interface{}) error
- func (c *Client) Get(ctx context.Context, endpoint string, v interface{}) error
- func (c *Client) Post(ctx context.Context, endpoint string, body interface{}, v interface{}) error
- func (c *Client) Put(ctx context.Context, endpoint string, body interface{}, v interface{}) error
- type ClientOption
- type ErrorResponse
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 an HTTP client that handles common operations for Buildkite API requests
func NewClient ¶
func NewClient(token string, opts ...ClientOption) *Client
NewClient creates a new HTTP client with the given token and options
func (*Client) Do ¶
func (c *Client) Do(ctx context.Context, method, endpoint string, body interface{}, v interface{}) error
Do performs an HTTP request with the given method, endpoint, and body
type ClientOption ¶
type ClientOption func(*Client)
ClientOption is a function that modifies a Client
func WithBaseURL ¶
func WithBaseURL(baseURL string) ClientOption
WithBaseURL sets the base URL for API requests
func WithHTTPClient ¶
func WithHTTPClient(client *http.Client) ClientOption
WithHTTPClient sets the underlying HTTP client
func WithUserAgent ¶
func WithUserAgent(userAgent string) ClientOption
WithUserAgent sets the User-Agent header for requests
type ErrorResponse ¶
ErrorResponse represents an error response from the API
func (*ErrorResponse) Error ¶
func (e *ErrorResponse) Error() string
Error implements the error interface
Click to show internal directories.
Click to hide internal directories.