natsio/client/communication.go

27 lines
596 B
Go
Raw Normal View History

2022-08-18 10:47:47 +00:00
package client
import (
"encoding/json"
"github.com/Selly-Modules/natsio"
"github.com/Selly-Modules/natsio/subject"
)
// Communication ...
type Communication struct{}
// GetCommunication ...
func GetCommunication() Communication {
return Communication{}
}
// RequestHttp ...
func (c Communication) RequestHttp(p communication.CommunicationRequestHttp) (r *communication.CommunicationHttpResponse, err error) {
msg, err := natsio.GetServer().Request(subject.CommunicationRequestHTTP, toBytes(p))
if err != nil {
return nil, err
}
err = json.Unmarshal(msg.Data, &r)
return r, err
}