diff --git a/proxy/proxy.go b/proxy/proxy.go index c351fac5..1911fba8 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -84,19 +84,17 @@ func NewProxy(c Config) (*Proxy, error) { func (proxy *Proxy) ServeHTTP(w http.ResponseWriter, r *http.Request) { Info.Printf("%s %s", r.Method, r.URL) path := r.URL.Path + var i interceptor switch { case containerCreateRegexp.MatchString(path): - proxy.serveWithInterceptor(&createContainerInterceptor{proxy.client, proxy.dockerBridgeIP, proxy.WithDNS, proxy.WithIPAM}, w, r) + i = &createContainerInterceptor{proxy.client, proxy.dockerBridgeIP, proxy.WithDNS, proxy.WithIPAM} case containerStartRegexp.MatchString(path): - proxy.serveWithInterceptor(&startContainerInterceptor{proxy.client, proxy.WithDNS, proxy.WithIPAM}, w, r) + i = &startContainerInterceptor{proxy.client, proxy.WithDNS, proxy.WithIPAM} case execCreateRegexp.MatchString(path): - proxy.serveWithInterceptor(&createExecInterceptor{proxy.client, proxy.WithIPAM}, w, r) + i = &createExecInterceptor{proxy.client, proxy.WithIPAM} default: - proxy.serveWithInterceptor(&nullInterceptor{}, w, r) + i = &nullInterceptor{} } -} - -func (proxy *Proxy) serveWithInterceptor(i interceptor, w http.ResponseWriter, r *http.Request) { newClient(proxy.dial, i).ServeHTTP(w, r) }