From fc96248bcf8c3a0b7c345ea3a7b93929e0f36741 Mon Sep 17 00:00:00 2001 From: tanfarming Date: Fri, 9 Feb 2024 14:19:44 -0500 Subject: [PATCH] word --- ita/internal/utils.go | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/ita/internal/utils.go b/ita/internal/utils.go index 69645d9a..d72ec247 100644 --- a/ita/internal/utils.go +++ b/ita/internal/utils.go @@ -158,15 +158,26 @@ func getRetCcu() (int, error) { } func ret_rewrite_assets(oldDomain, newDomain string) error { - retCcuReq, _ := http.NewRequest("POST", "https://ret."+cfg.PodNS+":4000/api-internal/v1/rewrite_assets", - bytes.NewBuffer([]byte( - `{"old_domain":"`+oldDomain+`","new_domain":"`+newDomain+`"}`))) + jsonBody, _ := json.Marshal(map[string]string{ + "old_domain": oldDomain, + "new_domain": newDomain, + }) + retCcuReq, _ := http.NewRequest( + "POST", + "https://ret."+cfg.PodNS+":4000/api-internal/v1/rewrite_assets", + bytes.NewBuffer(jsonBody)) retCcuReq.Header.Add("x-ret-dashboard-access-key", cfg.RetApiKey) + retCcuReq.Header.Add("content-type", "application/json") resp, err := _httpClient.Do(retCcuReq) - + if err != nil { + return err + } body, _ := io.ReadAll(resp.Body) Logger.Sugar().Debugf("resp %v", string(body)) + if resp.StatusCode > 200 { + return errors.New(string(body)) + } return err }