23 lines
480 B
Go
23 lines
480 B
Go
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()
|
||
}
|