shared

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: MIT-0 Imports: 12 Imported by: 1 module, 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsStatus added in v1.5.0

func IsStatus(err error, code int) bool

IsStatus reports whether err, or any error it wraps, is a StatusError carrying the given HTTP status code.

func PathSegments added in v1.4.5

func PathSegments(segments ...string) string

PathSegments joins the given segments into a single URL path, skipping empty ones and percent-encoding each segment (RFC 3986). This makes identifiers containing special characters (spaces, Unicode, '?', '&', '#', '/') target the correct resource. Use url.QueryEscape for query values.

Types

type AuthMode

type AuthMode int
const (
	AuthModeNone AuthMode = iota
	AuthModeBasic
	AuthModeCookie
)

type Options added in v1.4.5

type Options struct {
	Url      string
	User     string
	Password string
	Db       string
	AuthMode AuthMode
	// Timeout bounds each individual request. Zero (the default) means
	// 120 seconds.
	Timeout time.Duration
	// Logging enables request logging; LogWrite must be non-nil when true,
	// otherwise NewConnection returns an error.
	Logging  bool
	LogWrite func(string)
}

Options configures a new connection.

type StatusError added in v1.5.0

type StatusError struct {
	StatusCode int
	Detail     string // server body excerpt, truncated to maxErrorDetail
}

StatusError describes a non-2xx response from the server. Use IsStatus (or errors.Is with a StatusError target) to inspect the status code programmatically instead of parsing the message.

func (*StatusError) Error added in v1.5.0

func (e *StatusError) Error() string

func (*StatusError) Is added in v1.5.0

func (e *StatusError) Is(target error) bool

Is lets errors.Is(err, &StatusError{StatusCode: http.StatusConflict}) match any StatusError carrying the same status code.

type Transport added in v1.4.5

type Transport interface {
	DoRequest(ctx context.Context, method string, path string, body []byte) ([]byte, error)
	DoRequestWithDB(ctx context.Context, method string, db string, path string, body []byte) ([]byte, error)
	DoHeadRequest(ctx context.Context, path string) (*http.Response, error)
	Db() string
}

Transport is the HTTP transport abstraction used by the client sub-packages.

Contract for path arguments:

  • path must arrive PRE-ESCAPED; build it with PathSegments (or append an escaped query string yourself, e.g. "?rev="+url.QueryEscape(rev)).
  • db is passed RAW; DoRequestWithDB percent-encodes it internally.
  • An empty db falls back to the connection's database; if that is also unset, the call fails with a "database name not provided" error.

func NewConnection added in v1.4.5

func NewConnection(o Options) (Transport, error)

NewConnection creates a new connection implementing Transport.

Jump to

Keyboard shortcuts

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