middleware

package
v0.0.0-...-f412c9c Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2025 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAuthenticationFailed = fmt.Errorf("authentication failed")

ErrAuthenticationFailed indicates that authentication failed in the networking middleware.

Functions

func AddAuthenticationHeader

func AddAuthenticationHeader(
	authenticator auth.Authenticator,
	config configuration.Configuration,
	request *http.Request,
) error

AddAuthenticationHeader determines whether a request needs authentication, negotiates authorization and sets request headers if necessary.

If this fails due to an authentication error, the resulting error will match ErrAuthenticationFailed.

func ApplyTlsConfig

func ApplyTlsConfig(transport *http.Transport, insecure bool, caPool *x509.CertPool) *http.Transport

func ConfigureProxy

func ConfigureProxy(
	transport *http.Transport,
	logger *zerolog.Logger,
	proxy func(req *http.Request) (*url.URL, error),
	authenticationMechanism httpauth.AuthenticationMechanism,
) *http.Transport

func HandleResponse

func HandleResponse(res *http.Response, config configuration.Configuration) error

HandleResponse maps the response param to the eror catalog error.

func ShouldRequireAuthentication

func ShouldRequireAuthentication(
	apiUrl string,
	url *url.URL,
	additionalSubdomains []string,
	additionalUrls []string,
) (matchesPattern bool, err error)

Types

type AuthHeaderMiddleware

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

func NewAuthHeaderMiddleware

func NewAuthHeaderMiddleware(
	config configuration.Configuration,
	authenticator auth.Authenticator,
	roundTripper http.RoundTripper,
) *AuthHeaderMiddleware

func (*AuthHeaderMiddleware) RoundTrip

func (n *AuthHeaderMiddleware) RoundTrip(request *http.Request) (*http.Response, error)

type ResponseMiddleware

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

func NewReponseMiddleware

func NewReponseMiddleware(roundTriper http.RoundTripper, config configuration.Configuration, errHandler networktypes.ErrorHandlerFunc) *ResponseMiddleware

func (ResponseMiddleware) RoundTrip

func (rm ResponseMiddleware) RoundTrip(req *http.Request) (*http.Response, error)

Jump to

Keyboard shortcuts

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