2022-01-15 22:19:29 +01:00
|
|
|
package meowlib
|
|
|
|
|
|
|
|
import (
|
|
|
|
"crypto/tls"
|
|
|
|
|
|
|
|
"github.com/go-resty/resty/v2"
|
|
|
|
"github.com/rs/zerolog/log"
|
|
|
|
)
|
|
|
|
|
2022-03-01 10:37:11 +01:00
|
|
|
type Https struct {
|
|
|
|
url string
|
2022-01-15 22:19:29 +01:00
|
|
|
}
|
|
|
|
|
2022-03-01 10:37:11 +01:00
|
|
|
func (https *Https) Send(msg []byte) ([]byte, error) {
|
2022-01-15 22:19:29 +01:00
|
|
|
client := resty.New().SetTLSClientConfig(&tls.Config{InsecureSkipVerify: true})
|
|
|
|
|
|
|
|
resp, err := client.R().
|
|
|
|
SetHeader("Content-Type", "application/json").
|
|
|
|
SetBody(msg).
|
2022-03-01 10:37:11 +01:00
|
|
|
Post(https.url + "/message/add/")
|
2022-01-15 22:19:29 +01:00
|
|
|
if err != nil {
|
|
|
|
log.Error().Msg(err.Error())
|
|
|
|
}
|
2022-03-01 10:37:11 +01:00
|
|
|
return resp.Body(), err
|
2022-01-15 22:19:29 +01:00
|
|
|
}
|
|
|
|
|
2022-03-01 10:37:11 +01:00
|
|
|
func (https *Https) Start(callback *func() []InternalMessage) {
|
|
|
|
for {
|
2022-01-15 22:19:29 +01:00
|
|
|
|
2022-03-01 10:37:11 +01:00
|
|
|
}
|
2022-01-15 22:19:29 +01:00
|
|
|
}
|
|
|
|
|
2022-03-01 10:37:11 +01:00
|
|
|
func (https *Https) Stop() {
|
2022-01-15 22:19:29 +01:00
|
|
|
for {
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|