Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsStatus ¶ added in v1.5.0
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
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 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
NewConnection creates a new connection implementing Transport.