|
|
@ -29,6 +29,7 @@ var flags struct {
|
|
29
|
29
|
proxyClientKey string
|
|
30
|
30
|
|
|
31
|
31
|
proxyMinikube bool
|
|
|
32
|
proxy bool
|
|
32
|
33
|
cache bool
|
|
33
|
34
|
}
|
|
34
|
35
|
|
|
|
@ -39,6 +40,7 @@ func init() {
|
|
39
|
40
|
flag.StringVar(&flags.proxyClientKey, "proxy-client-key", "", "Client key to use when connecting to proxy")
|
|
40
|
41
|
|
|
41
|
42
|
flag.BoolVar(&flags.proxyMinikube, "proxy-minikube", false, "Shortcut for -proxy-url https://$(minikube ip):8443 -proxy-client-cert ~/.minikube/client.crt -proxy-client-key ~/.minikube/client.key")
|
|
|
43
|
flag.BoolVar(&flags.proxy, "proxy", false, "Proxy requests to any website")
|
|
42
|
44
|
flag.BoolVar(&flags.cache, "cache", false, "Cache all requests")
|
|
43
|
45
|
}
|
|
44
|
46
|
|
|
|
@ -75,8 +77,12 @@ func main() {
|
|
75
|
77
|
stub := responses.Match(req)
|
|
76
|
78
|
haveCachedStub := flags.cache && stub != nil
|
|
77
|
79
|
var resp *http.Response
|
|
78
|
|
if flags.proxyURL != "" && !haveCachedStub {
|
|
79
|
|
resp = respondWithProxy(flags.proxyURL, &cert, w, req)
|
|
|
80
|
if (flags.proxy || flags.proxyURL != "") && !haveCachedStub {
|
|
|
81
|
proxyURL := flags.proxyURL
|
|
|
82
|
if flags.proxy {
|
|
|
83
|
proxyURL = req.RequestURI
|
|
|
84
|
}
|
|
|
85
|
resp = respondWithProxy(proxyURL, &cert, w, req)
|
|
80
|
86
|
} else {
|
|
81
|
87
|
resp = respondWithStub(stub, w, req)
|
|
82
|
88
|
}
|