http

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2024 License: BSD-2-Clause Imports: 1 Imported by: 0 modules, 0 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.

Documentation

Overview

Package http provides HTTP client implementations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	Do(req *http.Request) (*http.Response, error)
}

A Client is implemented by the standard library's http.Client and TokenClient.

type TokenClient

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

A TokenClient wraps an HTTP client to automatically set Authorization headers in requests using the provided function to generate tokens.

func NewTokenClient

func NewTokenClient(c Client, tf func() string) *TokenClient

NewTokenClient returns a TokenClient given a client and token-generating funtion.

func (*TokenClient) Do

func (c *TokenClient) Do(req *http.Request) (*http.Response, error)

Do makes an HTTP request using the underlying client. If the token function returns a non-empty string then it will be set as the Authorization header of the request.

Jump to

Keyboard shortcuts

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