rts-sim-testing-service/dynamics/http.go

23 lines
480 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package dynamics
import (
"bytes"
"encoding/json"
"errors"
"net/http"
"strconv"
)
func SendTrainInitReq(info *InitTrainInfo) error {
ip := "127.0.0.1"
uri := "/api/aerodynamics/init/train"
url := "http://" + ip + uri
data, _ := json.Marshal(info)
resp, _ := http.Post(url, "application/json", bytes.NewBuffer(data))
if resp.StatusCode != http.StatusOK {
return errors.New("响应的http状态码" + strconv.Itoa(resp.StatusCode))
}
return resp.Body.Close()
}