package main import ( "fmt" "io" "log" "net/http" "net/url" ) // It can be improved by using some seedr.cc API // but it is generic enough for now // generated by claude.ai initially, hand modified const ( folder = "some-folder-name" file1URL = "some-hard-coded-url" ) func getProxyUrlForURL(u *url.URL) string { fmt.Println(u.String()) switch u.String() { case "/" + folder + "/file1.ext": return file1URL } return "" } func main() { proxyHandler := func(w http.ResponseWriter, r *http.Request) { // Create the proxy request proxyURL := getProxyUrlForURL(r.URL) req, err := http.NewRequest(r.Method, proxyURL, r.Body) if err != nil { http.Error(w, "Bad request", http.StatusBadRequest) return } // Copy headers req.Header = r.Header.Clone() // Send the request resp, err := http.DefaultClient.Do(req) if err != nil { http.Error(w, "Failed to reach upstream server", http.StatusBadGateway) return } defer resp.Body.Close() // Copy the response headers and body for k, v := range resp.Header { for _, vv := range v { w.Header().Add(k, vv) } } w.WriteHeader(resp.StatusCode) io.Copy(w, resp.Body) } http.HandleFunc("/", proxyHandler) log.Println("Proxy server listening on http://localhost:3832") log.Fatal(http.ListenAndServe(":3832", nil)) }