Help us shape the future of Go! Take the 2026 Go Developer Survey

http

package
v4.0.11 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2023 License: Apache-2.0 Imports: 1 Imported by: 0

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