package mtiwss import ( "bytes" "io/ioutil" "net/http" ) // Endpoint is the default MtiWss HTTP POST path const Endpoint = "/mtiwss/request/submit" // Mtiwss performs HTTP POST calls to the MTIWss HTTP service type Mtiwss struct { uri string } // New returns a new Mtiwss which does calls to URI func New(URI string) *Mtiwss { return &Mtiwss{uri: URI} } // Request does a HTTP POST request as Content-Type: text/json and returns the raw response func (m *Mtiwss) Request(body []byte) ([]byte, error) { r, err := http.Post(m.uri, "text/json", bytes.NewReader(body)) if err != nil { return nil, err } resp, err := ioutil.ReadAll(r.Body) if err != nil { return nil, err } if err := r.Body.Close(); err != nil { return nil, err } return resp, nil }