27 lines
596 B
Go
27 lines
596 B
Go
|
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
|
||
|
}
|