services

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	BaseURL    string
	HTTPClient *http.Client
	Headers    map[string]string
}

Client represents an optimized API client with connection pooling

func NewClient

func NewClient(baseURL string) *Client

NewClient creates a new optimized API client

func NewClientWithConfig

func NewClientWithConfig(config *ClientConfig) *Client

NewClientWithConfig creates a new API client with custom configuration

func (*Client) Close

func (c *Client) Close()

Close closes the underlying HTTP client

func (*Client) Delete

func (c *Client) Delete(path string, result any, opts *RequestOptions) error

Delete performs a DELETE request

func (*Client) Get

func (c *Client) Get(path string, result any, opts *RequestOptions) error

Get performs a GET request

func (*Client) Patch

func (c *Client) Patch(path string, body, result any, opts *RequestOptions) error

Patch performs a PATCH request

func (*Client) Post

func (c *Client) Post(path string, body, result any, opts *RequestOptions) error

Post performs a POST request

func (*Client) Put

func (c *Client) Put(path string, body, result any, opts *RequestOptions) error

Put performs a PUT request

type ClientConfig

type ClientConfig struct {
	BaseURL             string
	Timeout             time.Duration
	MaxIdleConns        int
	MaxIdleConnsPerHost int
	IdleConnTimeout     time.Duration
	DialTimeout         time.Duration
	KeepAlive           time.Duration
	TLSHandshakeTimeout time.Duration
}

ClientConfig holds configuration for the API client

func DefaultClientConfig

func DefaultClientConfig(baseURL string) *ClientConfig

DefaultClientConfig returns optimized defaults for the API client

type RequestOptions

type RequestOptions struct {
	Headers      map[string]string
	QueryParams  map[string]string
	Timeout      time.Duration
	Context      context.Context
	ResponseType string // "json", "text", "binary"
	Retries      int
	RetryDelay   time.Duration
}

RequestOptions provides options for API requests

Jump to

Keyboard shortcuts

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