http

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIClient

type APIClient struct {
	BaseURL    string
	HTTPClient *http.Client
	// contains filtered or unexported fields
}

APIClient represents the HTTP client.

func NewAPIClient

func NewAPIClient(baseURL string, token string, config APIClientConfig) *APIClient

NewAPIClient initializes a new API client.

func (*APIClient) MakeRequest

func (c *APIClient) MakeRequest(params RequestParams) (*APIResponse, error)

MakeRequest performs an HTTP request and returns the response.

type APIClientConfig

type APIClientConfig struct {
	MaxIdleConns          int
	MaxIdleConnsPerHost   int
	MaxConnsPerHost       int
	IdleConnTimeout       time.Duration
	TLSHandshakeTimeout   time.Duration
	ExpectContinueTimeout time.Duration
	DisableKeepAlives     bool
	DialTimeout           time.Duration
	DialKeepAlive         time.Duration
	RequestTimeout        time.Duration
}

APIClientConfig holds the configuration values for the API client.

func DefaultAPIClientConfig

func DefaultAPIClientConfig() APIClientConfig

DefaultAPIClientConfig returns the default configuration for the API client.

type APIResponse

type APIResponse struct {
	StatusCode int         // HTTP status code
	Headers    http.Header // Response headers
	Body       []byte      // Raw response body
}

APIResponse represents a generic API response.

type ErrorResponse

type ErrorResponse struct {
	Status  int    `json:"status"`
	Message string `json:"message"`
}

ErrorResponse represents a structured error response.

func ParseError

func ParseError(responseBody []byte) (*ErrorResponse, error)

ParseError attempts to parse a JSON error response.

type RequestParams

type RequestParams struct {
	Method      string            // HTTP method (GET, POST, PUT, etc.)
	Path        string            // API endpoint path
	Headers     map[string]string // HTTP headers
	QueryParams map[string]string // Query parameters
	Body        interface{}       // Request body
}

RequestParams defines the input parameters for making an API request.

Jump to

Keyboard shortcuts

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