30 lines
542 B
Go
30 lines
542 B
Go
|
package requests
|
||
|
|
||
|
import (
|
||
|
"log"
|
||
|
"net/http"
|
||
|
"os/exec"
|
||
|
"time"
|
||
|
|
||
|
"github.com/elazarl/goproxy"
|
||
|
)
|
||
|
|
||
|
var ProxyAddress = "localhost:58080"
|
||
|
|
||
|
func init() {
|
||
|
log.SetFlags(log.Lshortfile | log.LstdFlags)
|
||
|
go func() {
|
||
|
proxy := goproxy.NewProxyHttpServer()
|
||
|
proxy.Verbose = true
|
||
|
http.ListenAndServe(ProxyAddress, proxy)
|
||
|
}()
|
||
|
|
||
|
cmd := exec.Command("/bin/bash", "-c", "docker ps | grep httpbin")
|
||
|
_, err := cmd.Output()
|
||
|
if err != nil {
|
||
|
log.Println("recommend docker run -p 80:80 kennethreitz/httpbin ")
|
||
|
}
|
||
|
|
||
|
time.Sleep(time.Millisecond * 100)
|
||
|
}
|