MCPcopy
hub / github.com/yusing/godoxy / dockerSocketHandler

Function dockerSocketHandler

socket-proxy/pkg/handler.go:24–41  ·  view source on GitHub ↗
(socket string)

Source from the content-addressed store, hash-verified

22var DockerSocketHandler = dockerSocketHandler
23
24func 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
43func endpointNotAllowed(w http.ResponseWriter, _ *http.Request) {
44 http.Error(w, "Endpoint not allowed", http.StatusForbidden)

Callers

nothing calls this directly

Calls 5

ServeHTTPMethod · 0.95
dialDockerSocketFunction · 0.85
StringMethod · 0.65
SetMethod · 0.45
HeaderMethod · 0.45

Tested by

no test coverage detected