MCPcopy Create free account
hub / github.com/actiontech/dtle / InvokePostApiWithJson

Function InvokePostApiWithJson

api/handler/common.go:82–92  ·  view source on GitHub ↗
(url string, reqJson []byte, respStruct interface{})

Source from the content-addressed store, hash-verified

80}
81
82func InvokePostApiWithJson(url string, reqJson []byte, respStruct interface{}) error {
83 resp, err := http.Post(url, "application/json", bytes.NewReader(reqJson))
84 if err != nil {
85 return fmt.Errorf("invoke nomad api failed, error: %v", err)
86 }
87 defer resp.Body.Close()
88 if err := handleNomadResponse(resp.Body, resp.StatusCode, &respStruct); nil != err {
89 return fmt.Errorf("response contains error: %v", err)
90 }
91 return nil
92}
93
94func InvokeHttpUrlWithBody(method, url string, body []byte, respStruct interface{}) error {
95 req, err := http.NewRequest(method, url, bytes.NewReader(body))

Callers 4

createOrUpdateJobFunction · 0.92
sentSignalToTaskFunction · 0.92
ValidateJobV2Function · 0.92

Calls 2

handleNomadResponseFunction · 0.85
CloseMethod · 0.45

Tested by

no test coverage detected