Documentation
¶
Overview ¶
Package base provides a base HTTP client with logging middleware for calling other services.
Index ¶
Constants ¶
View Source
const ( // RateLimitWarningThreshold is the number of remaining requests before a warning is logged. RateLimitWarningThreshold = 5 // RateLimitWarningMsg is the message logged when the number of remaining requests is below the warning threshold. RateLimitWarningMsg = "API requests nearing rate limit" // RateLimitHitMsg is the message logged when the number of remaining requests is 0. RateLimitHitMsg = "API rate limit hit, sleeping until limit reset" )
Variables ¶
This section is empty.
Functions ¶
func NewTransport ¶
func NewTransport(options ...Option) http.RoundTripper
NewTransport creates a new base transport with logging middleware for use as the base transport for other clients
Types ¶
type LoggingTransport ¶
type LoggingTransport struct {
// Base is the underlying HTTP transport
Base http.RoundTripper
// Logger is the logger to use for logging
Logger zerolog.Logger
// Component identifies the service making the request
Component string
}
LoggingTransport is an HTTP transport that logs requests and responses
type Option ¶
type Option func(*baseOptions)
Option can modify how the base client works
func WithBaseTransport ¶
func WithBaseTransport(base http.RoundTripper) Option
WithBaseTransport sets the base transport to use for the client
func WithComponent ¶
WithComponent sets the component used
func WithLogger ¶
WithLogger sets the logger to use for logging requests and responses
Click to show internal directories.
Click to hide internal directories.