httputils

package
v0.0.0-...-7f48f6c Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeBody

func DecodeBody[Out any](l *zap.Logger, r *http.Request) (*Out, error)

func ExtractJWTBearerToken

func ExtractJWTBearerToken(r *http.Request) (string, error)

func ExtractRequestID

func ExtractRequestID(r *http.Request) string

func GetRequestDuration

func GetRequestDuration(ctx context.Context) (time.Duration, error)

func RetryPolicy

func RetryPolicy(ctx context.Context, resp *http.Response, err error) (bool, error)

RetryPolicy is a custom wrapper around retryablehttp.DefaultRetryPolicy. It treats `429 Too Many Requests` as non-retryable, so the application can decide how to deal with rate-limiting.

func RobustHTTPClient

func RobustHTTPClient(logger *zap.Logger) *http.Client

Types

type LeveledZap

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

func (LeveledZap) Debug

func (l LeveledZap) Debug(msg string, keysAndValues ...interface{})

func (LeveledZap) Error

func (l LeveledZap) Error(msg string, keysAndValues ...interface{})

re-writes HTTP client ERROR to WARN level (because of retries)

func (LeveledZap) Info

func (l LeveledZap) Info(msg string, keysAndValues ...interface{})

func (LeveledZap) Warn

func (l LeveledZap) Warn(msg string, keysAndValues ...interface{})

Jump to

Keyboard shortcuts

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