Skip to content

Commit

Permalink
word
Browse files Browse the repository at this point in the history
  • Loading branch information
tanfarming committed Feb 8, 2024
1 parent d267d6d commit 751c8de
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ita/internal/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,15 @@ var Restore = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {

})

var RewriteAssets = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
err := ret_rewrite_assets(r.Header.Get("old_domain"), r.Header.Get("new_domain"))
if err != nil {
http.Error(w, "failed", http.StatusInternalServerError)
return
}
fmt.Fprintf(w, "done")
})

var Z_dummy = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "req: %v, rAdr: %v, xff: %v", w.Header().Get("X-Request-Id"), r.RemoteAddr, r.Header["X-Forwarded_for"])
})
17 changes: 17 additions & 0 deletions ita/internal/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package internal
import (
"archive/tar"
"archive/zip"
"bytes"
"compress/gzip"
"context"
"crypto/tls"
Expand All @@ -12,6 +13,7 @@ import (
"hash/fnv"
"image"
"io"
"io/ioutil"
"math"
"net/http"
"os"
Expand Down Expand Up @@ -156,6 +158,21 @@ func getRetCcu() (int, error) {
return retCcuResp["count"], nil
}

func ret_rewrite_assets(oldDomain, newDomain string) error {
retCcuReq, _ := http.NewRequest("GET", "https://ret."+cfg.PodNS+":4000/api-internal/v1/rewrite_assets",
bytes.NewBuffer([]byte(
`{"old_domain":"`+oldDomain+`","new_domain":"`+newDomain+`"}`)))
retCcuReq.Header.Add("x-ret-dashboard-access-key", cfg.RetApiKey)

resp, err := _httpClient.Do(retCcuReq)

if err != nil {
body, _ := ioutil.ReadAll(resp.Body)
fmt.Println("resp", string(body))
}
return err
}

func waitRetCcu() error {
timeout := 6 * time.Hour
wait := 30 * time.Second
Expand Down

0 comments on commit 751c8de

Please sign in to comment.