transport

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 4, 2021 License: Apache-2.0 Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NoOpSigner

type NoOpSigner struct{}

NoOpSigner is a signer that does nothing. This signer should only be used by tests.

func DefaultSigner

func DefaultSigner() *NoOpSigner

DefaultSigner returns a default, no-op signer. This signer should only be used by tests.

func (*NoOpSigner) SignRequest

func (s *NoOpSigner) SignRequest(crypto.PrivateKey, string, *http.Request, []byte) error

SignRequest does nothing.

type Request

type Request struct {
	URL    *url.URL
	Header http.Header
}

Request contains the destination URL and headers.

func NewRequest

func NewRequest(toURL *url.URL) *Request

NewRequest returns a new request.

type Signer

type Signer interface {
	SignRequest(pKey crypto.PrivateKey, pubKeyID string, r *http.Request, body []byte) error
}

Signer signs an HTTP request and adds the signature to the header of the request.

type Transport

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

Transport implements a client-side transport that Gets and Posts requests using HTTP signatures.

func Default

func Default() *Transport

Default returns a default transport that uses the default HTTP client and no HTTP signatures. This transport should only be used by tests.

func New

func New(client httpClient, privateKey crypto.PrivateKey, publicKeyID *url.URL,
	getSigner, postSigner Signer) *Transport

New returns a new transport.

func (*Transport) Get

func (t *Transport) Get(ctx context.Context, r *Request) (*http.Response, error)

Get sends an HTTP GET. The HTTP request is first signed and the signature is added to the request header.

func (*Transport) Post

func (t *Transport) Post(ctx context.Context, r *Request, payload []byte) (*http.Response, error)

Post posts an HTTP request. The HTTP request is first signed and the signature is added to the request header.

Jump to

Keyboard shortcuts

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