mirror of
https://git.mills.io/saltyim/saltyim.git
synced 2024-06-30 18:51:03 +00:00
21 lines
495 B
Go
21 lines
495 B
Go
package saltyim
|
|
|
|
import (
|
|
"bytes"
|
|
"net/http"
|
|
|
|
log "github.com/sirupsen/logrus"
|
|
)
|
|
|
|
// Send sends the encrypted message `msg` to the Endpoint `endpoint` using a
|
|
// `POST` request and returns nil on success or an error on failure.
|
|
func Send(endpoint, msg string) error {
|
|
res, err := Request(http.MethodPost, endpoint, nil, bytes.NewBufferString(msg))
|
|
if err != nil {
|
|
log.WithError(err).Errorf("error publishing message to %s", endpoint)
|
|
return err
|
|
}
|
|
defer res.Body.Close()
|
|
return nil
|
|
}
|