http

package
v0.0.0-...-9dac4f2 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2023 License: BSD-2-Clause, MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete

func Delete(ctx context.Context, url string, param map[string]interface{}, result interface{}, opts ...Option) error

func Get

func Get(ctx context.Context, url string, result interface{}, opts ...Option) error

func Post

func Post(ctx context.Context, url string, param map[string]interface{}, result interface{}, opts ...Option) error

func Put

func Put(ctx context.Context, url string, param map[string]interface{}, result interface{}, opts ...Option) error

Types

type IHttp

type IHttp interface {
	// Get get
	Get(ctx context.Context, url string, result interface{}, opts ...Option) error
	// Post post
	Post(ctx context.Context, url string, param map[string]interface{}, result interface{}, opts ...Option) error
	// Put put
	Put(ctx context.Context, url string, param map[string]interface{}, result interface{}, opts ...Option) error
	// Delete delete
	Delete(ctx context.Context, url string, param map[string]interface{}, result interface{}, opts ...Option) error
}

func NewHttp

func NewHttp() IHttp

type ILogger

type ILogger interface {
	Println(a ...interface{})
}

type Method

type Method string
const (
	DefaultTimeOut        = 3 * time.Second
	MethodPost     Method = "POST"
	MethodGet      Method = "GET"
	MethodPut      Method = "PUT"
	MethodDelete   Method = "DELETE"
)

type Option

type Option interface {
	// contains filtered or unexported methods
}

func WithDeleteURIFlag

func WithDeleteURIFlag(flag bool) Option

func WithHeader

func WithHeader(headers map[string]string) Option

func WithLog

func WithLog(log ILogger) Option

func WithMethod

func WithMethod(method Method) Option

func WithParam

func WithParam(params map[string]interface{}) Option

func WithPreDeal

func WithPreDeal(preDeal func(r *Parameter) error) Option

func WithResponse

func WithResponse(response *nethttp.Response) Option

func WithTLSClientConfig

func WithTLSClientConfig(tLSClientConfig *tls.Config) Option

func WithTimeout

func WithTimeout(timeout time.Duration) Option

func WithUrl

func WithUrl(url string) Option

type Parameter

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

Parameter 参数

func (*Parameter) SetBody

func (p *Parameter) SetBody(body io.Reader)

Jump to

Keyboard shortcuts

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