-
Notifications
You must be signed in to change notification settings - Fork 0
/
rest-end.go
43 lines (35 loc) · 1.12 KB
/
rest-end.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package abango
import (
"encoding/json"
"strings"
e "github.com/dabory/abango-rest/etc"
)
//////////// Kafka EndPoint /////////////
func RestRequest(v *AbangoAsk) (string, string, error) {
svars := make(map[string]string)
for _, p := range v.ServerParams {
svars[p.Key] = p.Value
}
apiMethod := strings.ToUpper(svars["api_method"])
if apiMethod == "" { // Default is POST
apiMethod = "POST"
}
askBytes, _ := json.Marshal(&v)
if apiMethod == "POST" {
if retstr, retsta, err := e.GetHttpResponse(apiMethod, XConfig["RestConnect"], askBytes); err == nil {
return string(retstr), string(retsta), nil
} else {
return "", "", err
}
} else if apiMethod == "UPLOAD" {
// httpRtn, statusCode, err = getUploadHttpResponse(apiMethod, _apiUrlPrefix+apiUri, postBytes)
// if err != nil {
// return C.CString(sndrDisconnect(statusCode, err))
// // return sndrDisconnect(statusCode, err)
// }
// }
return "", "", e.MyErr("WERZDDERUVE-api_method not available UPLOAD-["+apiMethod+"]", nil, true)
} else {
return "", "", e.MyErr("WERZDDERUVE-api_method not available ["+apiMethod+"]", nil, true)
}
}