http

package
v0.0.107 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const ErrorCode = -1

Variables

View Source
var DefaultTransport = &http.Transport{
	DialContext: (&net.Dialer{
		Timeout: 500 * time.Millisecond,
	}).DialContext,
	TLSHandshakeTimeout: 1000 * time.Millisecond,
	MaxIdleConns:        100,
	IdleConnTimeout:     30 * time.Second,
}

Functions

This section is empty.

Types

type Client

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

func NewHttpClient

func NewHttpClient(transport *http.Transport, logger logging.Logger, url string) *Client

func (*Client) Delete

func (h *Client) Delete(params []KeyValue, body interface{}, header []KeyValue) (error, int, []byte)

func (*Client) Get

func (h *Client) Get(params []KeyValue, body interface{}, header []KeyValue) (error, int, []byte)

func (*Client) Post

func (h *Client) Post(params []KeyValue, body interface{}, header []KeyValue) (error, int, []byte)

func (*Client) Put

func (h *Client) Put(params []KeyValue, body interface{}, header []KeyValue) (error, int, []byte)

func (*Client) Request

func (h *Client) Request(method string, params []KeyValue, requestBody interface{}, headers []KeyValue) (err error, code int, respBody []byte)

type IHttpClient

type IHttpClient interface {
	Request(method string, params []KeyValue, body interface{}, header []KeyValue) (error, int, []byte)
	Get(params []KeyValue, body interface{}, header []KeyValue) (error, int, []byte)
	Post(params []KeyValue, body interface{}, header []KeyValue) (error, int, []byte)
	Delete(params []KeyValue, body interface{}, header []KeyValue) (error, int, []byte)
	Put(params []KeyValue, body interface{}, header []KeyValue) (error, int, []byte)
}

type KeyValue

type KeyValue struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

Jump to

Keyboard shortcuts

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