httpcli

package
v0.0.0-...-0350bc7 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Do

func Do[Resp any](sa *SingleAttempt, req any) (Resp, error)

Types

type Config

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

func NewConfig

func NewConfig() *Config

func (*Config) GetPatternUrl

func (conf *Config) GetPatternUrl(url string) string

func (*Config) SetPatternUrl

func (conf *Config) SetPatternUrl(url string) *Config

type HttpTemplate

type HttpTemplate struct {
	Client  *http.Client
	Encoder func(req any, sa *SingleAttempt) error
	Decoder func(sa *SingleAttempt) error
	Report  func(err error, sa *SingleAttempt, req, resp any)
}
var DefaultTemplate *HttpTemplate = NewHttpTemplate()

func NewHttpTemplate

func NewHttpTemplate() *HttpTemplate

func (*HttpTemplate) Do

func (template *HttpTemplate) Do(req, resp any, sa *SingleAttempt) (err error)

type SingleAttempt

type SingleAttempt struct {
	Request  *http.Request
	Response *http.Response

	RespBody []byte
	Template *HttpTemplate
	Conf     *Config
	// contains filtered or unexported fields
}

func NewSingleAttempt

func NewSingleAttempt(c context.Context, httpMethod, url string, conf *Config) *SingleAttempt

func (*SingleAttempt) Do

func (sa *SingleAttempt) Do(req any, resp any) (err error)

func (*SingleAttempt) GetResponseCode

func (sa *SingleAttempt) GetResponseCode() int

Jump to

Keyboard shortcuts

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