Documentation ¶
Index ¶
- Constants
- type APIKeyInfo
- type Okexv5APIResponse
- type RESTAPI
- func (this *RESTAPI) GenReqInfo() (uri string, body string, err error)
- func (this *RESTAPI) Get(ctx context.Context, uri string, param *map[string]interface{}) (res *RESTAPIResult, err error)
- func (this *RESTAPI) Post(ctx context.Context, uri string, param *map[string]interface{}) (res *RESTAPIResult, err error)
- func (this *RESTAPI) Post2(ctx context.Context, uri string, param *[]map[string]interface{}) (res *RESTAPIResult, err error)
- func (this *RESTAPI) PrintRequest(request *http.Request, body string, preHash string)
- func (this *RESTAPI) Run(ctx context.Context) (res *RESTAPIResult, err error)
- func (this *RESTAPI) SetAPIKey(apiKey, secKey, passPhrase string) *RESTAPI
- func (this *RESTAPI) SetHeaders(request *http.Request, timestamp string, sign string) (header string)
- func (this *RESTAPI) SetSimulate(b bool) *RESTAPI
- func (this *RESTAPI) SetTimeOut(timeout time.Duration) *RESTAPI
- func (this *RESTAPI) SetUserId(userId string) *RESTAPI
- type RESTAPIResult
Constants ¶
View Source
const ( /* http headers */ OK_ACCESS_KEY = "OK-ACCESS-KEY" OK_ACCESS_SIGN = "OK-ACCESS-SIGN" OK_ACCESS_TIMESTAMP = "OK-ACCESS-TIMESTAMP" OK_ACCESS_PASSPHRASE = "OK-ACCESS-PASSPHRASE" X_SIMULATE_TRADING = "x-simulated-trading" CONTENT_TYPE = "Content-Type" ACCEPT = "Accept" COOKIE = "Cookie" LOCALE = "locale=" APPLICATION_JSON = "application/json" APPLICATION_JSON_UTF8 = "application/json; charset=UTF-8" /* i18n: internationalization */ ENGLISH = "en_US" SIMPLIFIED_CHINESE = "zh_CN" //zh_TW || zh_HK TRADITIONAL_CHINESE = "zh_HK" GET = "GET" POST = "POST" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIKeyInfo ¶
type Okexv5APIResponse ¶
type RESTAPI ¶
type RESTAPI struct { EndPoint string `json:"endPoint"` // GET/POST Method string `json:"method"` Uri string `json:"uri"` Param map[string]interface{} `json:"param"` Param2 []map[string]interface{} `json:"param2"` Timeout time.Duration ApiKeyInfo *APIKeyInfo // contains filtered or unexported fields }
func NewRESTAPI ¶
func NewRESTClient ¶
func NewRESTClient(endPoint string, apiKey *APIKeyInfo, isSimulate bool) *RESTAPI
endPoint:请求地址 apiKey isSimulate: 是否为模拟环境
func (*RESTAPI) GenReqInfo ¶
生成请求对应的参数
func (*RESTAPI) Get ¶
func (this *RESTAPI) Get(ctx context.Context, uri string, param *map[string]interface{}) (res *RESTAPIResult, err error)
GET请求
func (*RESTAPI) Post ¶
func (this *RESTAPI) Post(ctx context.Context, uri string, param *map[string]interface{}) (res *RESTAPIResult, err error)
POST请求
func (*RESTAPI) Post2 ¶
func (this *RESTAPI) Post2(ctx context.Context, uri string, param *[]map[string]interface{}) (res *RESTAPIResult, err error)
POST2请求
func (*RESTAPI) PrintRequest ¶
打印header信息
func (*RESTAPI) SetHeaders ¶
func (this *RESTAPI) SetHeaders(request *http.Request, timestamp string, sign string) (header string)
Set http request headers: Accept: application/json Content-Type: application/json; charset=UTF-8 (default) Cookie: locale=en_US (English) OK-ACCESS-KEY: (Your setting) OK-ACCESS-SIGN: (Use your setting, auto sign and add) OK-ACCESS-TIMESTAMP: (Auto add) OK-ACCESS-PASSPHRASE: Your setting
func (*RESTAPI) SetSimulate ¶
type RESTAPIResult ¶
type RESTAPIResult struct { Url string `json:"url"` Param string `json:"param"` Header string `json:"header"` Code int `json:"code"` // 原始返回信息 Body string `json:"body"` // okexV5返回的数据 V5Response Okexv5APIResponse `json:"v5Response"` ReqUsedTime time.Duration `json:"reqUsedTime"` TotalUsedTime time.Duration `json:"totalUsedTime"` }
Click to show internal directories.
Click to hide internal directories.