1
This commit is contained in:
@@ -3,6 +3,7 @@ package topsdk
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
util2 "git.rosy.net.cn/baseapi/platformapi/tao_vegetable/sdk/util"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
@@ -12,7 +13,6 @@ import (
|
|||||||
"net/url"
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
util2 "topsdk/util"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type TopClient struct {
|
type TopClient struct {
|
||||||
@@ -34,7 +34,6 @@ type HttpTransportConfig struct {
|
|||||||
MaxIdleConnsPerHost int
|
MaxIdleConnsPerHost int
|
||||||
IdleConnTimeout int64
|
IdleConnTimeout int64
|
||||||
MaxConnsPerHost int
|
MaxConnsPerHost int
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewDefaultTopClient(AppKey string, AppSecret string, ServerUrl string, connectTimeount int64, readTimeout int64) TopClient {
|
func NewDefaultTopClient(AppKey string, AppSecret string, ServerUrl string, connectTimeount int64, readTimeout int64) TopClient {
|
||||||
@@ -49,7 +48,6 @@ func NewDefaultTopClient(AppKey string,AppSecret string,ServerUrl string, connec
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func NewTopClientWithConfig(AppKey string, AppSecret string, ServerUrl string, connectTimeount int64, readTimeout int64, httpTransportConfig *HttpTransportConfig) TopClient {
|
func NewTopClientWithConfig(AppKey string, AppSecret string, ServerUrl string, connectTimeount int64, readTimeout int64, httpTransportConfig *HttpTransportConfig) TopClient {
|
||||||
httpClient := http.Client{
|
httpClient := http.Client{
|
||||||
Timeout: time.Duration(connectTimeount) * time.Millisecond,
|
Timeout: time.Duration(connectTimeount) * time.Millisecond,
|
||||||
@@ -80,9 +78,6 @@ func NewTopClientWithConfig(AppKey string,AppSecret string,ServerUrl string, con
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func (client *TopClient) ExecuteWithSession(method string, data map[string]interface{}, fileData map[string]interface{}, session string) (string, error) {
|
func (client *TopClient) ExecuteWithSession(method string, data map[string]interface{}, fileData map[string]interface{}, session string) (string, error) {
|
||||||
var publicParam = make(map[string]interface{})
|
var publicParam = make(map[string]interface{})
|
||||||
publicParam["method"] = method
|
publicParam["method"] = method
|
||||||
@@ -124,12 +119,12 @@ func doPost(urlPath string,data map[string]interface{},httpClient *http.Client)
|
|||||||
if resp != nil {
|
if resp != nil {
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
}
|
}
|
||||||
if(err != nil){
|
if err != nil {
|
||||||
log.Println("http.PostForm error", err)
|
log.Println("http.PostForm error", err)
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
body, err := ioutil.ReadAll(resp.Body)
|
body, err := ioutil.ReadAll(resp.Body)
|
||||||
if(err != nil){
|
if err != nil {
|
||||||
log.Println("ioutil.ReadAll", err)
|
log.Println("ioutil.ReadAll", err)
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
@@ -172,7 +167,7 @@ func doPostWithFile(urlPath string,data map[string]interface{},fileData map[stri
|
|||||||
}
|
}
|
||||||
|
|
||||||
err := writer.Close()
|
err := writer.Close()
|
||||||
if(err != nil){
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,10 +185,6 @@ func doPostWithFile(urlPath string,data map[string]interface{},fileData map[stri
|
|||||||
return string(body), nil
|
return string(body), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (client *TopClient) Execute(method string, data map[string]interface{}, fileData map[string]interface{}) (string, error) {
|
func (client *TopClient) Execute(method string, data map[string]interface{}, fileData map[string]interface{}) (string, error) {
|
||||||
return client.ExecuteWithSession(method, data, fileData, "")
|
return client.ExecuteWithSession(method, data, fileData, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user