httputil

package
v4.7.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClient added in v4.6.0

func NewClient(ctx context.Context, localOnly bool) (*http.Client, error)

NewClient constructs an http.Client that disallows access to public networks, controlled by the localOnly flag.

If disallowed, the reported error will be a *net.AddrError with the "Err" value of "disallowed by policy".

func NewRequestWithContext added in v4.6.0

func NewRequestWithContext(ctx context.Context, method, url string, body io.Reader) (*http.Request, error)

NewRequestWithContext is a wrapper around http.NewRequestWithContext that sets some defaults in the returned request.

func RateLimiter

func RateLimiter(next http.RoundTripper) http.RoundTripper

RateLimiter wraps the provided RoundTripper with a limiter allowing 10 requests/second/host.

It responds to HTTP 429 responses by automatically decreasing the rate.

Types

type Signer added in v4.6.0

type Signer struct {
	// contains filtered or unexported fields
}

Signer signs requests.

func NewSigner added in v4.6.0

func NewSigner(ctx context.Context, cfg *config.Config, cl jwt.Claims) (*Signer, error)

NewSigner constructs a signer according to the provided Config and claim.

The returned Signer only adds headers for the hosts specified in the following spots:

  • $.notifier.webhook.target
  • $.notifier.indexer_addr
  • $.notifier.matcher_addr
  • $.matcher.indexer_addr

func (*Signer) Add added in v4.6.0

func (s *Signer) Add(ctx context.Context, uri string) error

Add marks the authority in "uri" as one that expects signed requests.

func (*Signer) Sign added in v4.6.0

func (s *Signer) Sign(ctx context.Context, req *http.Request) error

Sign modifies the passed http.Request as needed.

Jump to

Keyboard shortcuts

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