File size: 1,834 Bytes
04f1444 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | // Code generated by @openmeter/typespec-go. DO NOT EDIT.
package openmeter
import (
"net/http"
"runtime/debug"
)
// Version is the SDK version reported in the default User-Agent. When the SDK
// is consumed as a module dependency it is resolved from the consumer's build
// info (the module version selected by their go.mod), so tagged releases need
// no stamping commit. Builds where that is unavailable — the module itself,
// replace directives, vendored trees without version data — fall back to the
// sdk-version emitter option ("0.0.0-dev").
var Version = resolveVersion()
func resolveVersion() string {
if info, ok := debug.ReadBuildInfo(); ok {
for _, dep := range info.Deps {
if dep.Path != "github.com/openmeterio/openmeter/api/v3/client" || dep.Replace != nil {
continue
}
if dep.Version != "" && dep.Version != "(devel)" {
return dep.Version
}
}
}
return "0.0.0-dev"
}
var defaultUserAgent = "openmeter-go-sdk/" + Version
// Option configures a Client during New.
type Option func(*Client)
// WithToken sets the bearer token sent in the Authorization header of every
// request. The header is applied during request construction, so it is honored
// regardless of any client injected via WithHTTPClient.
func WithToken(token string) Option {
return func(c *Client) {
c.token = token
}
}
// WithHTTPClient replaces the default *http.Client. The provided client owns all
// transport behavior: retries, timeouts, proxies, TLS, and tracing. Pass nil to
// keep the default.
func WithHTTPClient(hc *http.Client) Option {
return func(c *Client) {
if hc != nil {
c.httpClient = hc
}
}
}
// WithUserAgent overrides the User-Agent header sent with each request.
func WithUserAgent(ua string) Option {
return func(c *Client) {
if ua != "" {
c.userAgent = ua
}
}
}
|