util

package
v0.0.0-...-b31de41 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2021 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SignTypeMD5        = `MD5`
	SignTypeHMACSHA256 = `HMAC-SHA256`
)
View Source
const (
	HTTP_TEST_WEB_URL = "http://css.pekcbec.com/css"
	HTTP_BASE_WEB_URL = "http://css.ubonex.com"
)

Variables

This section is empty.

Functions

func CalculateSign

func CalculateSign(content, signType, key string) (string, error)

CalculateSign compute sign

func DecodeWithCommonError

func DecodeWithCommonError(response []byte, apiName string) (err error)

DecodeWithCommonError 将返回值按照CommonError解析

func DecodeWithError

func DecodeWithError(response []byte, obj interface{}, apiName string) error

DecodeWithError 将返回值按照解析

func GetCurrStr

func GetCurrStr() string

GetCurrStr return current timestamps

func GetCurrTS

func GetCurrTS() int64

GetCurrTS return current timestamps

func GetCurrTSStr

func GetCurrTSStr() string

GetCurrTSStr return current timestamps

func HTTPGet

func HTTPGet(uri string) ([]byte, error)

HTTPGet get request

func HTTPPost

func HTTPPost(uri string, data string) ([]byte, error)

HTTPPost post request

func Interface2String

func Interface2String(inter interface{}) (str string)

func NewHTTPPost

func NewHTTPPost(uri string, data string) ([]byte, error)

func OrderParam

func OrderParam(p map[string]string, bizKey string) (returnStr string)

OrderParam trade params

func ParamSign

func ParamSign(p map[string]string, key string) (string, error)

ParamSign cumpute param sing

func PostFile

func PostFile(fieldname, filename, uri string) ([]byte, error)

PostFile upload file

func PostJSON

func PostJSON(uri string, obj interface{}) ([]byte, error)

PostJSON post json data request

func PostJSONWithRespContentType

func PostJSONWithRespContentType(uri string, obj interface{}) ([]byte, string, error)

PostJSONWithRespContentType post json data request,and return data type

func PostMultipartForm

func PostMultipartForm(fields []MultipartFormField, uri string) (respBody []byte, err error)

PostMultipartForm upload file or other multi field

func PostXML

func PostXML(uri string, obj interface{}) ([]byte, error)

PostXML perform a HTTP/POST request with XML body

func PostXMLWithTLS

func PostXMLWithTLS(uri string, obj interface{}, ca, key string) ([]byte, error)

PostXMLWithTLS perform a HTTP/POST request with XML body and TLS

Types

type CommonError

type CommonError struct {
	Success bool   `json:"success"`
	RetCode string `json:"retCode"`
	RetMsg  string `json:"retMsg"`
}

CommonError hongyuan return common error json

type CommonReq

type CommonReq struct {
	Version   string `json:"version"`   //版本号	version	String	是	2.0
	EnteCode  string `json:"enteCode"`  //CSS内部定义企业代码。网易客户该字段需带网易merchantId值。
	Timestamp string `json:"timestamp"` //yyyy-MM-ddHH:mm:ss
	Sign      string `json:"sign"`      //MD5签名的明文结构:enteCode=1111&orderNo=11111&timestamp=2016-01-01 12:00:00
}

type MultipartFormField

type MultipartFormField struct {
	IsFile    bool
	Fieldname string
	Value     []byte
	Filename  string
}

MultipartFormField save file or other field information

Jump to

Keyboard shortcuts

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