5763a158ddde5465484f3e98e6bc4b32469313d0
[ric-plt/a1.git] / pkg / notification / notification.go
1 package notification
2
3 import (
4         "bytes"
5         "net/http"
6
7         "gerrit.o-ran-sc.org/r/ric-plt/a1/pkg/a1"
8 )
9
10 func SendNotification(notificationDestination string, body string) error {
11         a1.Logger.Debug("In SendNotification")
12         client := &http.Client{}
13         req, err := http.NewRequest("POST", notificationDestination, bytes.NewBuffer([]byte(body)))
14         if err != nil {
15                 return err
16         }
17         req.Header.Set("User-Agent", "a1mediator")
18         res, err := client.Do(req)
19         if err != nil {
20                 a1.Logger.Debug("Error sending POST message to %v+", notificationDestination)
21                 return err
22         }
23         a1.Logger.Debug("Notification response %s received from far-end", res.Status)
24         return nil
25 }