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: 6

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