httpclient

package
v2.0.0-beta12 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(cfg Config, opts ...Option) *resty.Client

New creates a new resty client

func NewRequest

func NewRequest(ctx context.Context, client *resty.Client, jwt string) *resty.Request

NewRequest creates a new request with the given context and jwt

func WrapClient

func WrapClient(client *resty.Client) *http.Client

WrapClient wraps the resty client to add request id to the request

Types

type Config

type Config struct {
	UserAgent          string        `koanf:"UserAgent"`          // User agent, Default: HttpClient/1.0
	Timeout            time.Duration `koanf:"timeout"`            // Timeout, Default: 60 seconds
	RetryCount         int           `koanf:"RetryCount"`         // Retry count, Default: 3
	Debug              bool          `koanf:"debug"`              // Enable debug log, include request and response. Default: false
	DisableRetry       bool          `koanf:"DisableRetry"`       // Disable retry, Default: false
	LogAllResponse     bool          `koanf:"LogAllResponse"`     // Log all response body, Default only json/xml. It only works when debug is true. Default: false
	MaxRequestBodySize int64         `koanf:"MaxRequestBodySize"` // Max request body size, Default: 5 * 1024 (5KB)
}

type Option

type Option func(*options)

func WithLogger

func WithLogger(logger zerolog.Logger) Option

WithLogger sets the logger for the httpclient

Jump to

Keyboard shortcuts

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