Back to godoc.org

Package http

v1.1.4
Latest Go to latest

The latest major version is .

Published: Feb 3, 2020 | License: Apache-2.0 | Module: github.com/chenguolin/go-common

Index

Constants

const (
	// HTTPSignatureSecret 秘钥
	HTTPSignatureSecret = "abcdefghijklnmop"
	// HTTPSignatureSalt 盐
	HTTPSignatureSalt = "abcdefghijklnmop"
	// SignatureField signature
	SignatureField = "signature"
)
const (
	// PublicKeyField public key
	PublicKeyField = "public_key"
)

func GenSignature

func GenSignature(c *gin.Context) string

GenSignature get http signature 1. get url path 2. sort request form params 3. combine params + secret + sigTime + salt 4. calculator md5 5. shuffle md5 byte

func Get

func Get(httpClient *http.Client, url string,
	header map[string]string, retry int) (*http.Response, error)

Get http get request @httpClient required @url required @body optional @header optional @retry required

func NewHTTPClient

func NewHTTPClient(timeout time.Duration) *http.Client

NewHTTPClient new http.Client should open keep alive

func Post

func Post(httpClient *http.Client, url string, body []byte,
	header map[string]string, retry int) (*http.Response, error)

Post http post request @httpClient required @url required @body optional @header optional @retry required

func VerifyAuthorization

func VerifyAuthorization(c *gin.Context) error

VerifyAuthorization verify authorization always return true mean verify pass, if return false mean verify failed

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier