shared

package
v0.0.0-...-2f05eaf Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LogAfterResponse

func LogAfterResponse(r *resty.Client, response *resty.Response) error

LogAfterResponse is a resty callback that logs the response of the request it uses the request context to get the requestID to sign the log and make easy to track the request in the logs

func LogBeforeRequest

func LogBeforeRequest(_ *resty.Client, request *resty.Request) error

LogBeforeRequest is a resty callback that logs the request before it is sent it uses the request context to set the requestID to sign the log and make easy to track the request in the logs

func LogError

func LogError(message, directory, function string, error error, args ...any)

func LogInfo

func LogInfo(message, directory, function string, error error, args ...any)

func LogRequest

func LogRequest(uuid, method, url, body string, request, headers any)

func LogResponse

func LogResponse(uuid, status, body, method, url string, headers any)

func LogWarn

func LogWarn(message, directory, function string, error error, args ...any)

func NewHTTPClient

func NewHTTPClient() *httpClient

NewHTTPClient returns a new instance of httpClient

Types

type ContextKey

type ContextKey string
const (
	LogHttpClient            = "shared/httpclient.go"
	RequestUUID   ContextKey = "request_uuid"
)

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request, resp any) (*http.Response, error)
}

HTTPClient is an interface that allows us to implements any http client library we want

Jump to

Keyboard shortcuts

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