mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-12 13:05:58 +08:00
add management interface and callback args optimization
This commit is contained in:
@@ -155,8 +155,9 @@ type config struct {
|
||||
AccessExpire int64 `yaml:"accessExpire"`
|
||||
}
|
||||
MessageCallBack struct {
|
||||
CallbackSwitch bool `yaml:"callbackSwitch"`
|
||||
CallbackUrl string `yaml:"callbackUrl"`
|
||||
CallbackSwitch bool `yaml:"callbackSwitch"`
|
||||
CallbackUrl string `yaml:"callbackUrl"`
|
||||
CallBackTimeOut int `yaml:"callbackTimeOut"`
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,9 +32,13 @@ const (
|
||||
Video = 104
|
||||
File = 105
|
||||
AtText = 106
|
||||
Merger = 107
|
||||
Card = 108
|
||||
Location = 109
|
||||
Custom = 110
|
||||
HasReadReceipt = 112
|
||||
Typing = 113
|
||||
Quote = 114
|
||||
Common = 200
|
||||
GroupMsg = 201
|
||||
|
||||
|
||||
@@ -29,22 +29,24 @@ func Get(url string) (response []byte, err error) {
|
||||
}
|
||||
|
||||
//application/json; charset=utf-8
|
||||
func Post(url string, data interface{}, contentType string) (content []byte, err error) {
|
||||
jsonStr, _ := json.Marshal(data)
|
||||
func Post(url string, data interface{}, timeOutSecond int) (content []byte, err error) {
|
||||
jsonStr, err := json.Marshal(data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonStr))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req.Header.Add("content-type", contentType)
|
||||
defer req.Body.Close()
|
||||
req.Close = true
|
||||
req.Header.Add("content-type", "application/json; charset=utf-8")
|
||||
|
||||
client := &http.Client{Timeout: 5 * time.Second}
|
||||
client := &http.Client{Timeout: time.Duration(timeOutSecond) * time.Second}
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
result, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user