httputils

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2025 License: Apache-2.0 Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(b bool)

Debug sets debug

func DebugAuth

func DebugAuth(b bool)

DebugAuth sets authentication debug

Types

type HttpClient

type HttpClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HttpClient performs an HTTP request. Can be implemented by mocks to perform convenient unit tests

type HttpService

type HttpService struct {
	BaseUrl          string
	CommonHeaders    map[string]string
	Client           HttpClient
	HandleRateLimits bool
	MaxRetryAttempts int
}

func (HttpService) Do

func (s HttpService) Do(
	ctx context.Context,
	method,
	url string,
	requestBody any,
	queries map[string]string,
	expectedStatus int,
	response any) error

type Request

type Request struct {
	Method  string
	Url     string
	Body    []byte
	Queries map[string]string
	Headers map[string]string
	Client  HttpClient

	HandleRateLimits bool
	MaxRetryAttempts int
}

func (*Request) Do

func (req *Request) Do(ctx context.Context) ([]byte, int, error)

Jump to

Keyboard shortcuts

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