httpc

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetJsonBody

func GetJsonBody(body interface{}) (buf io.ReadWriter, err error)

Types

type RateLimitError

type RateLimitError struct {
	Method string
	URL    string
	Err    error
}

func (*RateLimitError) Error

func (e *RateLimitError) Error() string

type Request

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

func NewRequest

func NewRequest(baseUrl string, headers map[string]string) *Request

NewRequest constructs a Request with a 200 QPS / burst 500 default rate limiter — dev-friendly, unopinionated. Any client that hits a third-party with a documented cap (Jupiter, Bungee, CoinGecko free tier, ...) should call SetRateLimit with the cap so a chatty poll doesn't blow the budget and 429 everyone.

func (*Request) Delete

func (r *Request) Delete(ctx context.Context, result interface{}, path string) error

func (*Request) Execute

func (r *Request) Execute(ctx context.Context, method string, url string, body io.Reader, result interface{}) error

func (*Request) ExecuteRaw

func (r *Request) ExecuteRaw(ctx context.Context, method string, url string, body io.Reader, result *bytes.Buffer) error

func (*Request) Get

func (r *Request) Get(ctx context.Context, result interface{}, path string, query url.Values) error

func (*Request) GetBase

func (r *Request) GetBase(path string) string

func (*Request) GetRaw

func (r *Request) GetRaw(ctx context.Context, result *bytes.Buffer, path string, query url.Values) error

func (*Request) Patch

func (r *Request) Patch(ctx context.Context, result interface{}, path string, body interface{}) error

func (*Request) Post

func (r *Request) Post(ctx context.Context, result interface{}, path string, body interface{}) error

func (*Request) PostWithOutEncoded

func (r *Request) PostWithOutEncoded(ctx context.Context, result interface{}, path string, body interface{}) error

func (*Request) PostWithPlain

func (r *Request) PostWithPlain(ctx context.Context, result interface{}, path string, body io.Reader) error

func (*Request) PostWithXWWWFormUrlencoded

func (r *Request) PostWithXWWWFormUrlencoded(ctx context.Context, result interface{}, path string, body interface{}) error

func (*Request) SetBaseUrl

func (r *Request) SetBaseUrl(url string)

func (*Request) SetHeader

func (r *Request) SetHeader(k, v string)

func (*Request) SetRateLimit

func (r *Request) SetRateLimit(qps float64, burst int)

SetRateLimit replaces the per-Request rate limiter. Every Execute / ExecuteRaw call already waits on r.limiter, so this is the single knob for outbound throughput.

qps is requests per second (fractional OK — 0.5 = 30/min). burst is the number of tokens the bucket can hold above steady state: small (1-3) for latency-sensitive polls where we WANT to feel the limit; larger (~qps) for batch sweeps that legitimately arrive in bursts. rate.Inf on qps disables limiting entirely.

Jump to

Keyboard shortcuts

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