(suffix string, reqBytes []byte)
| 19 | } |
| 20 | |
| 21 | func Send(suffix string, reqBytes []byte) (body []byte, err error) { |
| 22 | req, err := http.NewRequest(http.MethodPost, Api+suffix, bytes.NewBuffer(reqBytes)) |
| 23 | if err != nil { |
| 24 | common.Logger.Error(err.Error()) |
| 25 | return |
| 26 | } |
| 27 | req.Header.Set("Content-Type", "application/json") |
| 28 | req.Header.Set("Authorization", "Bearer "+common.GlobalObject.OpenAi.Key) |
| 29 | |
| 30 | client := &http.Client{} |
| 31 | resp, err := client.Do(req) |
| 32 | if err != nil { |
| 33 | common.Logger.Error(err.Error()) |
| 34 | return |
| 35 | } |
| 36 | defer resp.Body.Close() |
| 37 | |
| 38 | body, err = io.ReadAll(resp.Body) |
| 39 | return |
| 40 | } |
no outgoing calls
no test coverage detected