util

package
v0.0.0-...-735ef63 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

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

Get

func Post

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

Post

Types

type IHttp

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

func NewHttp

func NewHttp() IHttp

type Method

type Method string
const (
	HttpTimeOut        = 10 * time.Second
	HttpPost    Method = "POST"
	HttpGet     Method = "GET"
)

type Option

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

func WithHeader

func WithHeader(headers map[string]string) 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 WithTimeout

func WithTimeout(timeout time.Duration) Option

type Parameter

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

参数

func (*Parameter) SetBody

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

Directories

Path Synopsis
rpc

Jump to

Keyboard shortcuts

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