From f5461743f6542e6b4a793117e05777769f9c3377 Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期二, 15 八月 2023 10:51:52 +0800 Subject: [PATCH] 新增任务开启通知接口,接收到通知或去查询工艺模型 --- pkg/httpx/httpx.go | 17 +++++++++++++++-- 1 files changed, 15 insertions(+), 2 deletions(-) diff --git a/pkg/httpx/httpx.go b/pkg/httpx/httpx.go index 4e286fe..c909811 100644 --- a/pkg/httpx/httpx.go +++ b/pkg/httpx/httpx.go @@ -3,7 +3,8 @@ import ( "bytes" "encoding/json" - "io/ioutil" + "errors" + "io" "net/http" "time" ) @@ -33,9 +34,21 @@ } defer resp.Body.Close() - respBytes, err := ioutil.ReadAll(resp.Body) + respBytes, err := io.ReadAll(resp.Body) if err != nil { return nil, err } return respBytes, nil } + +func SendPostAndParseJson(url string, post, response interface{}) (err error) { + if response == nil { + return errors.New("response is not set") + } + + respBytes, err := SendPost(http.Header{}, url, post) + if err != nil { + return err + } + return json.Unmarshal(respBytes, &response) +} -- Gitblit v1.8.0