|
|
|
@ -8,6 +8,7 @@ import (
|
|
|
|
|
"net/http/httputil"
|
|
|
|
|
"net/url"
|
|
|
|
|
"os"
|
|
|
|
|
"os/exec"
|
|
|
|
|
"strings"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
@ -49,7 +50,12 @@ func (pr Proxy) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
os.WriteFile(strings.ReplaceAll(req.RequestURI, "/", "_")+".txt", body, 0666)
|
|
|
|
|
go func() {
|
|
|
|
|
mp3 := strings.ReplaceAll(req.RequestURI, "/", "_") + ".mp3"
|
|
|
|
|
os.WriteFile(mp3, body, 0666)
|
|
|
|
|
// on Mac: "sudo ln -s /usr/bin/open /usr/local/bin/play"
|
|
|
|
|
go exec.Command("play", mp3).Run()
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
// pass on the original body into a new body 'cause the original one has been read out already.
|
|
|
|
|
resp.Body = io.NopCloser(bytes.NewReader(body))
|
|
|
|
|