Documentation ¶
Index ¶
- func CloneRequest(r *http.Request) *http.Request
- func DrainBody(b io.ReadCloser) (r1, r2 io.ReadCloser, err error)
- func NewCacheTransport(rt http.RoundTripper, c cache.Cache) *cacheTransport
- func NewRatelimitTransport(rt http.RoundTripper) *ratelimitTransport
- func NewRevalidationTransport(rt http.RoundTripper, v validators.Validator) *revalidationTransport
- func NewThrottleTransport(rt http.RoundTripper, rtl ratelimit.Limiter) *throttleTransport
- func NewTransport(rt http.RoundTripper) *transport
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 NewCacheTransport ¶
func NewCacheTransport(rt http.RoundTripper, c cache.Cache) *cacheTransport
NewCacheTransport creates a new CacheTransport instance
CacheTransport is responsible for caching responses to the configured Cache implementation.
If the response to the request is found in cache, it sets headers If-None-Match, If-Modified-Since, X-Cache, X-Cache-Age
If the response received has X-Revalidated headers, the cached response age is refreshed to the current time
func NewRatelimitTransport ¶
func NewRatelimitTransport(rt http.RoundTripper) *ratelimitTransport
NewRatelimitTransport creates a new RatelimitTransport instance
RatelimitTransport is responsible for checking responses from requests for any Github related ratelimit errors
Upon ratelimit error, the request is retried after the recommend time by Github
This only considers Github API secondary limits, also considered as abuse rate limits
func NewRevalidationTransport ¶ added in v0.1.6
func NewRevalidationTransport(rt http.RoundTripper, v validators.Validator) *revalidationTransport
NewRevalidationTransport creates a new RevalidationTransport instance
RevalidationTransport is responsible for revalidating requests from cache based on their configured maximum age
On each request, it checks for X-Cache-Age headers. Upon success, determines the current age of the request and validates it against a Validator implementation
If the request is still considered valid by the Validator, returns a new empty response with status 304
The response will have X-Revalidated headers, indicating that the response was sent from this Transport
func NewThrottleTransport ¶
func NewThrottleTransport(rt http.RoundTripper, rtl ratelimit.Limiter) *throttleTransport
NewThrottleTransport creates a new ThrottleTransport instance
ThrottleTransport is responsible for throttling requests to the configured amount of requests/s
func NewTransport ¶
func NewTransport(rt http.RoundTripper) *transport
NewTransport initializes Transport instances
Types ¶
This section is empty.