(socket string)
| 22 | var DockerSocketHandler = dockerSocketHandler |
| 23 | |
| 24 | func dockerSocketHandler(socket string) http.HandlerFunc { |
| 25 | rp := &reverseproxy.ReverseProxy{ |
| 26 | Director: func(req *http.Request) { |
| 27 | req.URL.Scheme = "http" |
| 28 | req.URL.Host = "api.moby.localhost" |
| 29 | req.RequestURI = req.URL.String() |
| 30 | }, |
| 31 | Transport: &http.Transport{ |
| 32 | DialContext: dialDockerSocket(socket), |
| 33 | DisableCompression: true, |
| 34 | }, |
| 35 | } |
| 36 | |
| 37 | return func(w http.ResponseWriter, r *http.Request) { |
| 38 | w.Header().Set("Transfer-Encoding", "chunked") |
| 39 | rp.ServeHTTP(w, r) |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | func endpointNotAllowed(w http.ResponseWriter, _ *http.Request) { |
| 44 | http.Error(w, "Endpoint not allowed", http.StatusForbidden) |
nothing calls this directly
no test coverage detected