-
Notifications
You must be signed in to change notification settings - Fork 0
/
message_notify.go
36 lines (31 loc) · 791 Bytes
/
message_notify.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
package dada
import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"net/http"
)
// 消息通知 https://newopen.imdada.cn/#/development/file/messageIndex?_k=xwnkni
func (this *Client) GetMessageNotify(req *http.Request) (notity *MessageNotify, err error) {
if req == nil {
return nil, errors.New("request 参数不能为空")
}
if err = req.ParseForm(); err != nil {
return nil, err
}
notity = &MessageNotify{}
body, err := ioutil.ReadAll(req.Body)
if err = json.Unmarshal(body, notity); err != nil {
fmt.Printf("Unmarshal err, %v\n", err)
return nil, err
}
return notity, err
}
func (this *Client) AckMessageNotify(w http.ResponseWriter) {
AckMessageNotify(w)
}
func AckMessageNotify(w http.ResponseWriter) {
w.WriteHeader(http.StatusOK)
w.Write([]byte("ok"))
}