pkg

package
v0.0.0-...-5e287ce Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatJSON

func FormatJSON(raw []byte) (string, error)

FormatJSON is a default function to pretty-format a JSON body. It will also mask known fields which contain sensitive information.

func GetDefaultSensitiveHeaders

func GetDefaultSensitiveHeaders() []string

GetDefaultSensitiveHeaders returns the default list of headers to be masked

Types

type AuthResult

type AuthResult struct {
	Username string
	Project  string
	TokenID  string
}

func OpenStackEC2Auth

func OpenStackEC2Auth(identityClient *gophercloud.ServiceClient, ao *ec2tokens.AuthOptions) (*AuthResult, error)

type ILogger

type ILogger interface {
	RequestPrintf(format string, args ...interface{})
	ResponsePrintf(format string, args ...interface{})
}

ILogger is an interface representing the Logger struct

type Logger

type Logger struct{}

func (Logger) RequestPrintf

func (lg Logger) RequestPrintf(format string, args ...interface{})

func (Logger) ResponsePrintf

func (lg Logger) ResponsePrintf(format string, args ...interface{})

type NoopLogger

type NoopLogger struct{}

NoopLogger is a default noop logger satisfies the Logger interface

func (NoopLogger) RequestPrintf

func (NoopLogger) RequestPrintf(format string, args ...interface{})

Printf is a default noop method

func (NoopLogger) ResponsePrintf

func (NoopLogger) ResponsePrintf(format string, args ...interface{})

Printf is a default noop method

type RoundTripper

type RoundTripper struct {
	// Default http.RoundTripper
	Rt http.RoundTripper
	// Override request Host (e.g. call locahost, but send example.com HTTP host)
	Host *string

	// A custom function to format and mask JSON requests and responses
	FormatJSON func([]byte) (string, error)
	// How many times HTTP connection should be retried until giving up
	MaxRetries int
	// If Logger is not nil, then RoundTrip method will debug the JSON
	// requests and responses
	Logger ILogger
	// contains filtered or unexported fields
}

RoundTripper satisfies the http.RoundTripper interface and is used to customize the default http client RoundTripper

func (*RoundTripper) RoundTrip

func (rt *RoundTripper) RoundTrip(request *http.Request) (*http.Response, error)

RoundTrip performs a round-trip HTTP request and logs relevant information about it.

func (*RoundTripper) SetHeaders

func (rt *RoundTripper) SetHeaders(headers http.Header)

SetHeaders sets request headers to be set (not appended) in all client requests

func (*RoundTripper) SetSensitiveHeaders

func (rt *RoundTripper) SetSensitiveHeaders(headers []string)

SetSensitiveHeaders sets the list of case insensitive headers to be masked in debug log

Jump to

Keyboard shortcuts

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