Documentation
¶
Index ¶
- func CloneRequest(r *http.Request) *http.Request
- func DrainBody(b io.ReadCloser) (r1, r2 io.ReadCloser, err error)
- func IsRequestCacheable(req *http.Request) bool
- func NewTransport(rt http.RoundTripper, opts *TransportOpts) http.RoundTripper
- type CacheTransport
- type CacheTransportOptions
- type RatelimitTransport
- type RatelimitTransportOpts
- type ThrottleTransport
- type ThrottleTransportOptions
- type TransportOpts
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CloneRequest ¶
CloneRequest clones the HTTP request
func DrainBody ¶
func DrainBody(b io.ReadCloser) (r1, r2 io.ReadCloser, err error)
DrainBody reads all of 'b' to memory and returns two equivalent ReadCloser instances with the same number of bytes
func IsRequestCacheable ¶
IsRequestCacheable returns true if the request is cacheable, false otherwise
func NewTransport ¶
func NewTransport(rt http.RoundTripper, opts *TransportOpts) http.RoundTripper
NewTransport initializes Transport instances
Types ¶
type CacheTransport ¶
type CacheTransport struct {
Next http.RoundTripper
Opts *CacheTransportOptions
Cache cache.Cache
}
CacheTransport implements http.RoundTripper
func NewCacheTransport ¶
func NewCacheTransport(next http.RoundTripper, opts *CacheTransportOptions) *CacheTransport
NewCacheTransport initializes a new *CacheTransport instance
func (*CacheTransport) GetCacheKey ¶
func (t *CacheTransport) GetCacheKey(req *http.Request) string
func (*CacheTransport) GetCachedResponse ¶
type CacheTransportOptions ¶
type CacheTransportOptions struct {
}
CacheTransportOptions are options for CacheTransport
type RatelimitTransport ¶
type RatelimitTransport struct {
Next http.RoundTripper
Options *RatelimitTransportOpts
}
RatelimitTransport implements http.RoundTripper
func NewRatelimitTransport ¶
func NewRatelimitTransport(next http.RoundTripper, opts *RatelimitTransportOpts) *RatelimitTransport
NewRatelimitTransport initializes a new *RatelimitTransport instance
type RatelimitTransportOpts ¶
type RatelimitTransportOpts struct{}
RatelimitTransportOpts are options for RatelimitTransport
type ThrottleTransport ¶
type ThrottleTransport struct {
Next http.RoundTripper
Opts *ThrottleTransportOptions
Limiter ratelimit.Limiter
}
ThrottleTransport implements http.RoundTripper
func NewThrottleTransport ¶
func NewThrottleTransport(next http.RoundTripper, opts *ThrottleTransportOptions) *ThrottleTransport
NewThrottleTransport initializes a new *ThrottleTransport instance
type ThrottleTransportOptions ¶
type ThrottleTransportOptions struct {
RequestsPerSecond int
}
ThrottleTransportOptions are options for ThrottleTransport
type TransportOpts ¶
type TransportOpts struct {
RatelimitTransportEnabled bool
RatelimitTransportOpts *RatelimitTransportOpts
ThrottleTransportEnabled bool
ThrottleTransportOpts *ThrottleTransportOptions
CacheTransportEnabled bool
CacheTransportOpts *CacheTransportOptions
}
TransportOpts are options for creating new Transport instances