Documentation ¶
Index ¶
- func IsForbidden(err error) bool
- func IsNotFound(err error) bool
- func IsUnauthorized(err error) bool
- type Client
- type ClientError
- type ClientInterface
- type ClientOption
- func WithCorrelationClientName(clientName string) ClientOption
- func WithLogger(log *zap.Logger) ClientOption
- func WithRateLimiter(limiter httpz.Limiter) ClientOption
- func WithRetryConfig(retryConfig RetryConfig) ClientOption
- func WithTLSConfig(tlsConfig *tls.Config) ClientOption
- func WithTracer(tracer opentracing.Tracer) ClientOption
- func WithUserAgent(userAgent string) ClientOption
- type DoOption
- func WithAgentToken(agentToken api.AgentToken) DoOption
- func WithHeader(header http.Header) DoOption
- func WithJWT(withJWT bool) DoOption
- func WithJobToken(jobToken string) DoOption
- func WithJsonRequestBody(body interface{}) DoOption
- func WithMethod(method string) DoOption
- func WithPath(path string) DoOption
- func WithQuery(query url.Values) DoOption
- func WithRequestBody(body io.Reader, contentType string) DoOption
- func WithResponseHandler(handler ResponseHandler) DoOption
- func WithoutRetries() DoOption
- type GitalyInfo
- type GitalyRepository
- type HTTPClient
- type ResponseHandler
- type ResponseHandlerStruct
- type RetryConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsForbidden ¶
func IsNotFound ¶ added in v14.2.0
func IsUnauthorized ¶
Types ¶
type Client ¶
type Client struct { Backend *url.URL HTTPClient HTTPClient HTTPClientNoRetry HTTPClient AuthSecret []byte UserAgent string }
type ClientError ¶
type ClientError struct {
StatusCode int
}
func (ClientError) Error ¶
func (e ClientError) Error() string
type ClientInterface ¶
type ClientOption ¶
type ClientOption func(*clientConfig)
ClientOption to configure the client.
func WithCorrelationClientName ¶
func WithCorrelationClientName(clientName string) ClientOption
WithCorrelationClientName configures the X-GitLab-Client-Name header on the http client.
func WithRateLimiter ¶
func WithRateLimiter(limiter httpz.Limiter) ClientOption
WithRateLimiter sets the rate limiter to use.
func WithRetryConfig ¶ added in v14.3.0
func WithRetryConfig(retryConfig RetryConfig) ClientOption
WithRetryConfig configures retry behavior.
func WithTLSConfig ¶
func WithTLSConfig(tlsConfig *tls.Config) ClientOption
WithTLSConfig sets the TLS config to use.
func WithTracer ¶
func WithTracer(tracer opentracing.Tracer) ClientOption
WithTracer sets a custom tracer to be used, otherwise the opentracing.GlobalTracer is used.
func WithUserAgent ¶
func WithUserAgent(userAgent string) ClientOption
WithUserAgent configures the User-Agent header on the http client.
type DoOption ¶
type DoOption func(*doConfig) error
DoOption to configure the Do call of the client.
func WithAgentToken ¶
func WithAgentToken(agentToken api.AgentToken) DoOption
func WithHeader ¶
func WithJobToken ¶
func WithJsonRequestBody ¶
func WithJsonRequestBody(body interface{}) DoOption
func WithMethod ¶
func WithRequestBody ¶
WithRequestBody sets the request body and HTTP Content-Type header if contentType is not empty.
func WithResponseHandler ¶
func WithResponseHandler(handler ResponseHandler) DoOption
func WithoutRetries ¶ added in v14.4.0
func WithoutRetries() DoOption
type GitalyInfo ¶
type GitalyInfo struct { Address string `json:"address"` Token string `json:"token"` Features map[string]string `json:"features"` }
func (*GitalyInfo) ToGitalyInfo ¶
func (g *GitalyInfo) ToGitalyInfo() api.GitalyInfo
type GitalyRepository ¶
type GitalyRepository struct { StorageName string `json:"storage_name"` RelativePath string `json:"relative_path"` GlRepository string `json:"gl_repository"` GlProjectPath string `json:"gl_project_path"` }
func (*GitalyRepository) ToProtoRepository ¶
func (r *GitalyRepository) ToProtoRepository() *gitalypb.Repository
type HTTPClient ¶
type ResponseHandler ¶
type ResponseHandler interface { // Handle is invoked with HTTP client's response and error values. Handle(*http.Response, error) error // Accept returns the value to send in the Accept HTTP header. // Empty string means no value should be sent. Accept() string }
func JsonResponseHandler ¶
func JsonResponseHandler(response interface{}) ResponseHandler
func NakedResponseHandler ¶
func NakedResponseHandler(response **http.Response) ResponseHandler
func NoContentResponseHandler ¶
func NoContentResponseHandler() ResponseHandler
NoContentResponseHandler can be used when no response is expected or response must be discarded.
type ResponseHandlerStruct ¶
type ResponseHandlerStruct struct { AcceptHeader string HandleFunc func(*http.Response, error) error }
func (ResponseHandlerStruct) Accept ¶
func (r ResponseHandlerStruct) Accept() string
type RetryConfig ¶ added in v14.3.0
type RetryConfig struct { // Logger instance. Can be either retryablehttp.Logger or retryablehttp.LeveledLogger Logger interface{} RetryWaitMin time.Duration // Minimum time to wait RetryWaitMax time.Duration // Maximum time to wait RetryMax int // Maximum number of retries // RequestLogHook allows a user-supplied function to be called // before each retry. RequestLogHook retryablehttp.RequestLogHook // ResponseLogHook allows a user-supplied function to be called // with the response from each HTTP request executed. ResponseLogHook retryablehttp.ResponseLogHook // CheckRetry specifies the policy for handling retries, and is called // after each request. The default policy is retryablehttp.DefaultRetryPolicy. CheckRetry retryablehttp.CheckRetry // Backoff specifies the policy for how long to wait between retries. // retryablehttp.DefaultBackoff is used by default. Backoff retryablehttp.Backoff }