httpclient

package
v0.0.0-...-df769fd Latest Latest
Warning

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

Go to latest
Published: May 4, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package httpclient provides a thin HTTP client for the Frisco API. It handles auth headers, query params, body serialisation, automatic token refresh on 401, and sensitive-data sanitisation in error messages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CurrentRateLimit

func CurrentRateLimit() (float64, int)

CurrentRateLimit returns the active limiter settings.

func RequestJSON

func RequestJSON(s *session.Session, method, pathOrURL string, opts RequestOpts) (any, error)

RequestJSON performs an HTTP request and returns the parsed JSON response.

func SetRateLimit

func SetRateLimit(rps float64, burst int)

SetRateLimit configures the shared process-wide request limiter. rps <= 0 disables throttling.

Types

type DataFormat

type DataFormat string

DataFormat specifies how the request body should be encoded.

const (
	FormatJSON DataFormat = "json" // encode body as JSON
	FormatForm DataFormat = "form" // encode body as application/x-www-form-urlencoded
	FormatRaw  DataFormat = "raw"  // send body string as-is
)

DataFormat constants define supported body encoding formats.

type ErrorDetails

type ErrorDetails struct {
	Status int    `json:"status"`
	Reason string `json:"reason"`
	URL    string `json:"url,omitempty"`
	Body   string `json:"body,omitempty"`
}

func ParseError

func ParseError(err error) (*ErrorDetails, bool)

func (*ErrorDetails) Error

func (e *ErrorDetails) Error() string

type RequestOpts

type RequestOpts struct {
	Query        []string
	Data         any
	DataFormat   DataFormat
	ExtraHeaders map[string]string
	Client       *http.Client
}

RequestOpts bundles optional arguments for RequestJSON.

Jump to

Keyboard shortcuts

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