Documentation
¶
Index ¶
- Variables
- func GetExpandFields(fieldIds ...string) string
- func GetJwt(key Key, iss string, sub string, aud string, scopes []string, expiresIn int64) (string, error)
- func GetRsa256Key(privateKeyFilePath string) rsa256Key
- func GetRsa256KeyFromPEMBytes(privateKeyBytes []byte) rsa256Key
- func GetRsa256KeyFromPEMString(privateKeyString string) rsa256Key
- func NormalizeURLForTracing(rawURL string) string
- type ApiError
- type ApiErrorImpl
- func (e *ApiErrorImpl) Error() string
- func (e *ApiErrorImpl) GetDescription() string
- func (e *ApiErrorImpl) GetMissingScopes() []string
- func (e *ApiErrorImpl) GetStatusCode() int
- func (e *ApiErrorImpl) HasToRequestScopes() bool
- func (e *ApiErrorImpl) IsMissingScopes() bool
- func (e *ApiErrorImpl) RequestScopesUrl() string
- func (e *ApiErrorImpl) Unwrap() error
- type BinaryMetadata
- type BinaryResponse
- type ClientOption
- type ClientOptions
- type ClientOptionsImpl
- func (co *ClientOptionsImpl) GetAudience() string
- func (co *ClientOptionsImpl) GetBasePath() string
- func (co *ClientOptionsImpl) GetHost() string
- func (co *ClientOptionsImpl) GetProtocol() string
- func (co *ClientOptionsImpl) GetUrl() string
- func (co *ClientOptionsImpl) SetAudience(value string) ClientOptions
- func (co *ClientOptionsImpl) SetBasePath(value string) ClientOptions
- func (co *ClientOptionsImpl) SetHost(value string) ClientOptions
- func (co *ClientOptionsImpl) SetProtocol(value string) ClientOptions
- func (co *ClientOptionsImpl) SetUrl(value string) ClientOptions
- type ErrorObject
- type File
- type HttpClient
- type HttpClientImpl
- func (hc *HttpClientImpl) Get(res interface{}, url string, opts ...RequestOption) error
- func (hc *HttpClientImpl) GetStream(res BinaryResponse, url string, opts ...RequestOption) error
- func (hc *HttpClientImpl) Post(res interface{}, url string, payload interface{}, opts ...RequestOption) error
- func (hc *HttpClientImpl) PostWithFiles(res interface{}, url string, payload interface{}, files []File, ...) error
- func (hc *HttpClientImpl) Request(res interface{}, requestMethod string, url string, opts ...RequestOption) error
- func (hc *HttpClientImpl) RequestBinary(res BinaryResponse, requestMethod string, url string, opts ...RequestOption) error
- func (hc *HttpClientImpl) SetRequester(requester HttpClientRequester)
- type HttpClientRequester
- type HttpReqFuncType
- type Impersonation
- type ImpersonationImpl
- func (imp *ImpersonationImpl) GetAccessToken() string
- func (imp *ImpersonationImpl) GetAccessTokenExpires() time.Time
- func (imp *ImpersonationImpl) GetScopes() []string
- func (imp *ImpersonationImpl) GetSub() string
- func (imp *ImpersonationImpl) SetAccessToken(value string) Impersonation
- func (imp *ImpersonationImpl) SetAccessTokenExpires(value time.Time) Impersonation
- func (imp *ImpersonationImpl) SetScopes(value []string) Impersonation
- func (imp *ImpersonationImpl) SetSub(value string) Impersonation
- type Key
- type PageParams
- type PageParamsImpl
- type QueryParams
- type Request
- type RequestOption
- func WithExpand(paths ...string) RequestOption
- func WithHeader(name string, value string) RequestOption
- func WithPage(pageParams PageParams) RequestOption
- func WithPageParams(limit int, startingAfter string) RequestOption
- func WithQueryParam(qParam string, value string) RequestOption
- func WithQueryParamList(qParam string, values ...string) RequestOption
- func WithReqOptQueryParamList(name string, values []string) RequestOption
- func WithRequestHost(host string) RequestOption
- func WithUpdatedAfter(ts int) RequestOption
- type RequestOptions
- type RequestOptionsImpl
- type Response
- type Span
- type Tracer
- type TracingHttpClientConfig
Constants ¶
This section is empty.
Variables ¶
var ( ApiErrorHttpRequestMethod = "Error while initializing http request" ApiErrorHttpBodyResponse = "Error reading body response" ApiErrorHttpRequest = "Error when sending http request to Glide API" ApiErrorHttpReadResponse = "Error while reading response body" )
Functions ¶
func GetExpandFields ¶
func GetRsa256Key ¶
func GetRsa256Key(privateKeyFilePath string) rsa256Key
func GetRsa256KeyFromPEMBytes ¶
func GetRsa256KeyFromPEMBytes(privateKeyBytes []byte) rsa256Key
func GetRsa256KeyFromPEMString ¶
func GetRsa256KeyFromPEMString(privateKeyString string) rsa256Key
func NormalizeURLForTracing ¶ added in v6.0.100
NormalizeURLForTracing extracts the path from rawURL and replaces numeric segments with {num} to aggregate similar requests in tracing systems.
Types ¶
type ApiErrorImpl ¶
type ApiErrorImpl struct {
Description string
StatusCode int
ResponseHeaders http.Header
Params map[string]interface{}
Err error
}
func GetApiError ¶
func GetApiError(e error) *ApiErrorImpl
func NewApiErrorWithArgs ¶
func NewHttpMethodApiError ¶
func NewHttpMethodApiError(e error) *ApiErrorImpl
func NewHttpRequestApiError ¶
func NewHttpRequestApiError(e error) *ApiErrorImpl
func (*ApiErrorImpl) Error ¶
func (e *ApiErrorImpl) Error() string
func (*ApiErrorImpl) GetDescription ¶
func (e *ApiErrorImpl) GetDescription() string
func (*ApiErrorImpl) GetMissingScopes ¶
func (e *ApiErrorImpl) GetMissingScopes() []string
func (*ApiErrorImpl) GetStatusCode ¶
func (e *ApiErrorImpl) GetStatusCode() int
func (*ApiErrorImpl) HasToRequestScopes ¶
func (e *ApiErrorImpl) HasToRequestScopes() bool
func (*ApiErrorImpl) IsMissingScopes ¶
func (e *ApiErrorImpl) IsMissingScopes() bool
func (*ApiErrorImpl) RequestScopesUrl ¶
func (e *ApiErrorImpl) RequestScopesUrl() string
func (*ApiErrorImpl) Unwrap ¶
func (e *ApiErrorImpl) Unwrap() error
type BinaryMetadata ¶
type BinaryResponse ¶
type BinaryResponse interface {
SetData(dataSource io.Reader, metadata BinaryMetadata) error
}
type ClientOption ¶
type ClientOption func(options ClientOptions)
func WithAudience ¶
func WithAudience(audience string) ClientOption
func WithBasePath ¶
func WithBasePath(basePath string) ClientOption
func WithHost ¶
func WithHost(host string) ClientOption
func WithProtocol ¶
func WithProtocol(protocol string) ClientOption
func WithURL ¶
func WithURL(URL string) ClientOption
type ClientOptions ¶
type ClientOptions interface {
GetProtocol() string
GetHost() string
GetUrl() string
GetBasePath() string
GetAudience() string
SetProtocol(value string) ClientOptions
SetHost(value string) ClientOptions
SetUrl(value string) ClientOptions
SetBasePath(value string) ClientOptions
SetAudience(value string) ClientOptions
}
func NewClientOptions ¶
func NewClientOptions() ClientOptions
type ClientOptionsImpl ¶
type ClientOptionsImpl struct {
// contains filtered or unexported fields
}
func (*ClientOptionsImpl) GetAudience ¶
func (co *ClientOptionsImpl) GetAudience() string
func (*ClientOptionsImpl) GetBasePath ¶
func (co *ClientOptionsImpl) GetBasePath() string
func (*ClientOptionsImpl) GetHost ¶
func (co *ClientOptionsImpl) GetHost() string
func (*ClientOptionsImpl) GetProtocol ¶
func (co *ClientOptionsImpl) GetProtocol() string
func (*ClientOptionsImpl) GetUrl ¶
func (co *ClientOptionsImpl) GetUrl() string
func (*ClientOptionsImpl) SetAudience ¶
func (co *ClientOptionsImpl) SetAudience(value string) ClientOptions
func (*ClientOptionsImpl) SetBasePath ¶
func (co *ClientOptionsImpl) SetBasePath(value string) ClientOptions
func (*ClientOptionsImpl) SetHost ¶
func (co *ClientOptionsImpl) SetHost(value string) ClientOptions
func (*ClientOptionsImpl) SetProtocol ¶
func (co *ClientOptionsImpl) SetProtocol(value string) ClientOptions
func (*ClientOptionsImpl) SetUrl ¶
func (co *ClientOptionsImpl) SetUrl(value string) ClientOptions
type ErrorObject ¶
type HttpClient ¶
type HttpClient interface {
Get(res interface{}, url string, opts ...RequestOption) error
GetStream(res BinaryResponse, url string, opts ...RequestOption) error
Post(res interface{}, url string, payload interface{}, opts ...RequestOption) error
PostWithFiles(res interface{}, url string, payload interface{}, files []File, opts ...RequestOption) error
Request(res interface{}, requestMethod string, url string, opts ...RequestOption) error
RequestBinary(res BinaryResponse, requestMethod string, url string, opts ...RequestOption) error
SetRequester(requester HttpClientRequester)
}
func NewHttpClient ¶
func NewHttpClient() HttpClient
func NewHttpClientWithRequester ¶
func NewHttpClientWithRequester(requester HttpClientRequester) HttpClient
func NewTracingHttpClientDecorator ¶ added in v6.0.100
func NewTracingHttpClientDecorator(ctx context.Context, httpClient HttpClient, tracer Tracer, config TracingHttpClientConfig) HttpClient
NewTracingHttpClientDecorator wraps httpClient with distributed tracing via the provided Tracer. Each request starts a span tagged with the HTTP method, endpoint, payload, response, and duration.
ctx is captured at construction time and used as the parent for every span. This means the decorator must be constructed fresh for each request context scope — do not construct it once and reuse it across requests with different contexts, or all spans will be rooted under the trace that was active at construction time rather than the trace of each individual request.
type HttpClientImpl ¶
type HttpClientImpl struct {
// contains filtered or unexported fields
}
func (*HttpClientImpl) Get ¶
func (hc *HttpClientImpl) Get(res interface{}, url string, opts ...RequestOption) error
func (*HttpClientImpl) GetStream ¶
func (hc *HttpClientImpl) GetStream(res BinaryResponse, url string, opts ...RequestOption) error
func (*HttpClientImpl) Post ¶
func (hc *HttpClientImpl) Post(res interface{}, url string, payload interface{}, opts ...RequestOption) error
func (*HttpClientImpl) PostWithFiles ¶
func (hc *HttpClientImpl) PostWithFiles(res interface{}, url string, payload interface{}, files []File, opts ...RequestOption) error
func (*HttpClientImpl) Request ¶
func (hc *HttpClientImpl) Request(res interface{}, requestMethod string, url string, opts ...RequestOption) error
func (*HttpClientImpl) RequestBinary ¶
func (hc *HttpClientImpl) RequestBinary(res BinaryResponse, requestMethod string, url string, opts ...RequestOption) error
func (*HttpClientImpl) SetRequester ¶
func (hc *HttpClientImpl) SetRequester(requester HttpClientRequester)
type HttpClientRequester ¶
type Impersonation ¶
type Impersonation interface {
GetSub() string
GetScopes() []string
GetAccessToken() string
GetAccessTokenExpires() time.Time
SetSub(string) Impersonation
SetScopes([]string) Impersonation
SetAccessToken(string) Impersonation
SetAccessTokenExpires(time.Time) Impersonation
}
func NewImpersonation ¶
func NewImpersonation() Impersonation
type ImpersonationImpl ¶
type ImpersonationImpl struct {
// contains filtered or unexported fields
}
func (*ImpersonationImpl) GetAccessToken ¶
func (imp *ImpersonationImpl) GetAccessToken() string
func (*ImpersonationImpl) GetAccessTokenExpires ¶
func (imp *ImpersonationImpl) GetAccessTokenExpires() time.Time
func (*ImpersonationImpl) GetScopes ¶
func (imp *ImpersonationImpl) GetScopes() []string
func (*ImpersonationImpl) GetSub ¶
func (imp *ImpersonationImpl) GetSub() string
func (*ImpersonationImpl) SetAccessToken ¶
func (imp *ImpersonationImpl) SetAccessToken(value string) Impersonation
func (*ImpersonationImpl) SetAccessTokenExpires ¶
func (imp *ImpersonationImpl) SetAccessTokenExpires(value time.Time) Impersonation
func (*ImpersonationImpl) SetScopes ¶
func (imp *ImpersonationImpl) SetScopes(value []string) Impersonation
func (*ImpersonationImpl) SetSub ¶
func (imp *ImpersonationImpl) SetSub(value string) Impersonation
type Key ¶
type Key interface {
GetJwtSigningMethod() jwt.SigningMethod
GetDecoded() (crypto.PrivateKey, error)
}
type PageParams ¶
func NewPageParamsWith ¶
func NewPageParamsWith(limit int, startingAfter string) PageParams
type PageParamsImpl ¶
func (*PageParamsImpl) GetQueryParams ¶
func (p *PageParamsImpl) GetQueryParams() map[string]string
type QueryParams ¶
type RequestOption ¶
type RequestOption func(requestOptions *RequestOptionsImpl)
func WithExpand ¶
func WithExpand(paths ...string) RequestOption
func WithHeader ¶
func WithHeader(name string, value string) RequestOption
func WithPage ¶
func WithPage(pageParams PageParams) RequestOption
func WithPageParams ¶
func WithPageParams(limit int, startingAfter string) RequestOption
func WithQueryParam ¶
func WithQueryParam(qParam string, value string) RequestOption
func WithQueryParamList ¶
func WithQueryParamList(qParam string, values ...string) RequestOption
func WithReqOptQueryParamList ¶
func WithReqOptQueryParamList(name string, values []string) RequestOption
func WithRequestHost ¶
func WithRequestHost(host string) RequestOption
func WithUpdatedAfter ¶
func WithUpdatedAfter(ts int) RequestOption
type RequestOptions ¶
type RequestOptionsImpl ¶
type RequestOptionsImpl struct {
// contains filtered or unexported fields
}
func (*RequestOptionsImpl) GetHeaders ¶
func (reqOpt *RequestOptionsImpl) GetHeaders() http.Header
func (*RequestOptionsImpl) GetHost ¶
func (reqOpt *RequestOptionsImpl) GetHost() string
func (*RequestOptionsImpl) GetPayload ¶
func (reqOpt *RequestOptionsImpl) GetPayload() *bytes.Buffer
func (*RequestOptionsImpl) GetQParams ¶
func (reqOpt *RequestOptionsImpl) GetQParams() QueryParams
type Span ¶ added in v6.0.100
type Span interface {
SetTag(key string, value interface{})
Finish()
}
Span represents an active tracing span with tag and lifecycle management.
type Tracer ¶ added in v6.0.100
type Tracer interface {
StartSpanFromContext(ctx context.Context, operationName, serviceName, resourceName string) Span
}
Tracer is an interface for distributed tracing that can be injected into the SDK. Implementations should start a new span derived from the provided context.
type TracingHttpClientConfig ¶ added in v6.0.100
TracingHttpClientConfig holds the tracing metadata for a decorator instance.