http

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: MIT Imports: 17 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package http is the HTTP(S) JSON transport: GET requests only, basic and digest authentication, no redirects to other hosts, per-request timeouts and backoff after failures (spec 4.4, 10). It never sends anything but GET.

Index

Constants

View Source
const (
	AuthNone   = ""
	AuthBasic  = "basic"
	AuthDigest = "digest"
)

Authentication schemes.

View Source
const (
	BackoffMin  = time.Second
	BackoffMax  = 30 * time.Second
	MaxBodySize = 1 << 20 // 1 MiB

)

Backoff bounds and response limit.

Variables

View Source
var (
	ErrUnavailable  = errors.New("http: device unavailable")
	ErrUnauthorized = errors.New("http: unauthorized")
	ErrStatus       = errors.New("http: unexpected status")
	ErrRedirect     = errors.New("http: redirect to another host refused")
)

Errors returned by Get.

Functions

This section is empty.

Types

type Client

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

Client is the HTTP transport of one device. Get is called by one goroutine at a time (the collector of the connection).

func New

func New(s Settings, clock util.Clock, log zerolog.Logger) (*Client, error)

New builds a client; it does not contact the device.

func (*Client) Get

func (c *Client) Get(ctx context.Context, path string) ([]byte, error)

Get fetches path (with query). During backoff it fails fast with ErrUnavailable.

type Reader

type Reader interface {
	Get(ctx context.Context, path string) ([]byte, error)
}

Reader fetches a path relative to the base URL.

type Settings

type Settings struct {
	BaseURL  string // scheme://host[:port]
	Timeout  time.Duration
	Auth     string
	User     string
	Password string // sent to the device only, never logged
	Insecure bool   // skip TLS verification (insecure_tls)
}

Settings describes one device endpoint base.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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