util

package
v0.0.0-...-fac1178 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2021 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SignTypeMD5        = `MD5`
	SignTypeHMACSHA256 = `HMAC-SHA256`
)

ark sign method

View Source
const (
	BASE_BACK_URL  = "https://partner.kaola.com"               //商家后台
	USER_OAUTH_URL = "https://oauth.kaola.com/oauth/authorize" //用户授权地址
	BASE_API_URL   = "https://openapi.kaola.com/router"        //用户API请求地址
)

Variables

This section is empty.

Functions

func CalculateSign

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

CalculateSign calculate sign

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 请求

func HTTPGetContext

func HTTPGetContext(ctx context.Context, uri string) ([]byte, error)

HTTPGetContext get 请求

func HTTPPost

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

HTTPPost post 请求

func HTTPPostContext

func HTTPPostContext(ctx context.Context, uri string, data string) ([]byte, error)

HTTPPostContext post 请求

func NewHTTPPost

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

func OrderParam

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

OrderParam trade params

func ParamSign

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

ParamSign calculate param sign

func PostFile

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

PostFile 上传文件

func PostJSON

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

PostJSON post json 数据请求

func PostJSONWithRespContentType

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

PostJSONWithRespContentType post json数据请求,且返回数据类型

func PostMultipartForm

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

PostMultipartForm 上传文件或其他多个字段

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

func UrlParam

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

Types

type BasicError

type BasicError struct {
	ErrorMessage string `json:"error_message"`
	ErrorCode    string `json:"error_code"`
}

type CommonError

type CommonError struct {
	Code    string      `json:"code"`
	Data    interface{} `json:"data"`
	Message string      `json:"message"`
	Success bool        `json:"success"`
}

type MultipartFormField

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

MultipartFormField 保存文件或其他字段信息

type ReturnCommonError

type ReturnCommonError struct {
	RetCode    string `json:"retcode"`
	RetDesc    string `json:"retdesc"`
	SubRetCode string `json:"subretcode"`
	SubRetDesc string `json:"subretdesc"`
}

type SubError

type SubError struct {
	Code    string      `json:"code"`
	Msg     string      `json:"msg"`
	SubCode int         `json:"sub_code"`
	SubMsg  int         `json:"sub_msg"`
	Data    interface{} `json:"data"`
}

Jump to

Keyboard shortcuts

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