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

23 lines
480 B
Go
Raw Normal View History

2023-07-26 17:02:53 +08:00
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()
}