httptransport

package
v0.6.8 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2022 License: Apache-2.0 Imports: 2 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithBearerToken

func WithBearerToken(ctx context.Context, bearerToken string) context.Context

WithBearerToken inserts the bearer token into the returned context which is based on the provided context. If this context is then used with the HTTP request in a client having the AuthenticatingRoundTripper as its transport, the round tripper will insert this token into the Authorization header of the request.

Types

type AuthenticatingRoundTripper

type AuthenticatingRoundTripper struct {
	http.RoundTripper
}

AuthenticatingRoundTripper is a wrapper around an HTTP round tripper that add a bearer token from the context (if any) before performing the request using the wrapped round tripper.

func (AuthenticatingRoundTripper) RoundTrip

func (r AuthenticatingRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

type ExaminingRoundTripper

type ExaminingRoundTripper struct {
	http.RoundTripper
	Examiner RoundTripExaminer
}

ExaminingRoundTripper is an HTTP request round tripper that calls the Examiner after the request is made so that it can examine the request and response or turn it into an error.

func (ExaminingRoundTripper) RoundTrip

func (r ExaminingRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

type RoundTripExaminer

type RoundTripExaminer interface {
	Examine(req *http.Request, response *http.Response) error
}

RoundTripExaminer is interface enabling the implementors to examine the request and response during the roundtrip and potentially somehow modify them or turn them into error.

type RoundTripExaminerFunc

type RoundTripExaminerFunc func(*http.Request, *http.Response) error

RoundTripExaminerFunc is a conversion of a function into RoundTripExaminer

func (RoundTripExaminerFunc) Examine

func (r RoundTripExaminerFunc) Examine(req *http.Request, res *http.Response) error

Jump to

Keyboard shortcuts

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