httpwares

package module
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 27, 2023 License: MIT Imports: 6 Imported by: 3 modules, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

HTTP Transports

build codecov

A collection of useful http.RoundTripper implementations:

  • VerboseTransport wraps an instance of a http.RoundTripper to write the http.Request and http.Response
  • RateLimitTransport enables rate limit client requests by using a golang.org/x/time/rate/Limiter instance

See the test cases for how to use each http.RoundTripper

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContentTypes added in v0.1.0

func ContentTypes() []string

Types

type RateLimitTransport

type RateLimitTransport struct {
	Limiter   *rate.Limiter
	Transport http.RoundTripper
}

RateLimitTransport restricts the rate of api calls

func (*RateLimitTransport) RoundTrip

func (t *RateLimitTransport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip executes requests within the rate limit

type VerboseTransport

type VerboseTransport struct {
	Writer       io.Writer
	Transport    http.RoundTripper
	ContentTypes []string
}

VerboseTransport logs the request and response

func (*VerboseTransport) RoundTrip

func (t *VerboseTransport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip is a logging RoundTripper

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址