httpclient

package
v0.0.0-...-1569ab3 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Unknown      = -1
	NoAccess     = -2
	TokenFailure = -3
	Success      = 0
	Error        = 1
)

Variables

This section is empty.

Functions

func DecomposeResp

func DecomposeResp(response *http.Response, entity interface{}) error

func GET

func GET(uri string, entity interface{}) error

func GetHttpClient

func GetHttpClient() *http.Client

func MarshalNotHtml

func MarshalNotHtml(data interface{}) ([]byte, error)

MarshalNotHtml not encode html

func NewClient

func NewClient(conf *HttpConfig)

NewClient new a http client

func POST

func POST(ctx context.Context, uri string, params interface{}, entity interface{}) error

POST http post

func Request

func Request(uri string, method string, params interface{}, entity interface{}, headers map[string]string) error

Request http

Types

type HttpConfig

type HttpConfig struct {
	Timeout      time.Duration `yaml:"timeout"`
	MaxIdleConns int           `yaml:"maxIdleConns"`
}

type R

type R struct {
	Code int64       `json:"code"`
	Msg  string      `json:"msg,omitempty"`
	Data interface{} `json:"data,omitempty"`
	// contains filtered or unexported fields
}

func Format

func Format(resp resp, err error) *R

func (*R) Context

func (r *R) Context(c *gin.Context, code ...int)

Jump to

Keyboard shortcuts

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