utils

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const Accept = "application/json"
View Source
const RequestContentType = "application/json"
View Source
const ServiceName = "api"

Variables

This section is empty.

Functions

func EncodeGetParams

func EncodeGetParams(req map[string]string) string

EncodeGetParams encodes the post params, to the cactus format, like {param_name=[param_value], param_name2=[param_value2]} example:{b_id=[4a3e2fb40faa4b9d94480559ac01e8de], coin_names=[BTC,LTC], hide_no_coin_wallet=[false], total_market_order=[0]}

func EncodeGetQuery

func EncodeGetQuery(req map[string]string) string

func GenerateAuthorizationHeader

func GenerateAuthorizationHeader(signReq []byte, ApiKeyId string, key *ecdsa.PrivateKey) (string, error)

GenerateAuthorizationHeader generates the authorization header signReq: the string to be signed ApiKeyId: the api key id key: the private key

func GenerateSignString

func GenerateSignString(RequestMethod string, body []byte, XApiKey string, XApiNonce string, uri string, FormattedParams string, currentTime string) string

GenerateSignString generates the string to be signed RequestMethod: GET, POST, PUT, DELETE, use the constants in http/method.go body: the body of the request, if it's post request, pass nil XApiKey: the api key XApiNonce: the nonce uri: the uri of the request FormattedParams: the formatted params, if there's no params, pass "" currentTime: the current time in RFC1123 format, using GMT TZ

func GenerateUuid

func GenerateUuid() string

func GetCurrentGmtTime

func GetCurrentGmtTime() string

func Sign

func Sign(signReq []byte, key *ecdsa.PrivateKey) ([]byte, error)

Sign signs the string signReq: the string to be signed

Types

This section is empty.

Jump to

Keyboard shortcuts

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